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

fix tests and minor changes

- use the iterator in `CanonPath` to count `level`
- use the `CanonPath::basename` method
- use `CanonPath::root` instead of `CanonPath{""}`
- remove `Path` and `PathView`, use `std::filesystem::path` directly
This commit is contained in:
siddhantCodes 2024-07-03 17:34:02 +05:30
parent 72bb530141
commit 2cf24a2df0
7 changed files with 21 additions and 13 deletions

View file

@ -73,7 +73,9 @@ struct NarAccessor : public SourceAccessor
NarMember & createMember(const CanonPath & path, NarMember member)
{
size_t level = std::count(path.rel().begin(), path.rel().end(), '/');
size_t level = 0;
for (auto _ : path) ++level;
while (parents.size() > level) parents.pop();
if (parents.empty()) {
@ -83,7 +85,7 @@ 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.rel()), std::move(member));
auto result = parents.top()->children.emplace(*path.baseName(), std::move(member));
auto & ref = result.first->second;
parents.push(&ref);
return ref;