1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-04 08:00:59 +01:00
This commit is contained in:
Eelco Dolstra 2023-11-14 14:47:17 +01:00
parent 7f576f5dfe
commit c257c82447
3 changed files with 17 additions and 6 deletions

View file

@ -54,18 +54,16 @@ struct MountedInputAccessor : InputAccessor
std::pair<ref<InputAccessor>, CanonPath> resolve(CanonPath path)
{
// Find the nearest parent of `path` that is a mount point.
std::vector<std::string> ss;
std::vector<std::string> subpath;
while (true) {
auto i = mounts.find(path);
if (i != mounts.end()) {
auto subpath = CanonPath::root;
for (auto j = ss.rbegin(); j != ss.rend(); ++j)
subpath.push(*j);
return {i->second, std::move(subpath)};
std::reverse(subpath.begin(), subpath.end());
return {i->second, CanonPath(subpath)};
}
assert(!path.isRoot());
ss.push_back(std::string(*path.baseName()));
subpath.push_back(std::string(*path.baseName()));
path.pop();
}
}