1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-18 00:12:43 +01:00

Merge pull request #11018 from siddhantk232/canonpath-fs-sink

Use `CanonPath` in `fs-sink.hh`
This commit is contained in:
John Ericson 2024-07-03 10:36:18 -04:00 committed by GitHub
commit 30de61f16d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 82 additions and 80 deletions

View file

@ -71,9 +71,11 @@ struct NarAccessor : public SourceAccessor
: acc(acc), source(source)
{ }
NarMember & createMember(const Path & path, NarMember member)
NarMember & createMember(const CanonPath & path, NarMember member)
{
size_t level = std::count(path.begin(), path.end(), '/');
size_t level = 0;
for (auto _ : path) ++level;
while (parents.size() > level) parents.pop();
if (parents.empty()) {
@ -83,14 +85,14 @@ struct NarAccessor : public SourceAccessor
} else {
if (parents.top()->stat.type != Type::tDirectory)
throw Error("NAR file missing parent directory of path '%s'", path);
auto result = parents.top()->children.emplace(baseNameOf(path), std::move(member));
auto result = parents.top()->children.emplace(*path.baseName(), std::move(member));
auto & ref = result.first->second;
parents.push(&ref);
return ref;
}
}
void createDirectory(const Path & path) override
void createDirectory(const CanonPath & path) override
{
createMember(path, NarMember{ .stat = {
.type = Type::tDirectory,
@ -100,7 +102,7 @@ struct NarAccessor : public SourceAccessor
} });
}
void createRegularFile(const Path & path, std::function<void(CreateRegularFileSink &)> func) override
void createRegularFile(const CanonPath & path, std::function<void(CreateRegularFileSink &)> func) override
{
auto & nm = createMember(path, NarMember{ .stat = {
.type = Type::tRegular,
@ -112,7 +114,7 @@ struct NarAccessor : public SourceAccessor
func(nmc);
}
void createSymlink(const Path & path, const std::string & target) override
void createSymlink(const CanonPath & path, const std::string & target) override
{
createMember(path,
NarMember{