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:
commit
30de61f16d
12 changed files with 82 additions and 80 deletions
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue