mirror of
https://github.com/NixOS/nix
synced 2025-06-30 15:48:00 +02:00
Add CanonPath wrapper to represent canonicalized paths
This commit is contained in:
parent
de35e2d3b4
commit
a71f209330
31 changed files with 503 additions and 187 deletions
|
@ -7,7 +7,7 @@ struct PatchingInputAccessor : InputAccessor
|
|||
{
|
||||
ref<InputAccessor> next;
|
||||
|
||||
std::map<Path, std::vector<std::string>> patchesPerFile;
|
||||
std::map<CanonPath, std::vector<std::string>> patchesPerFile;
|
||||
|
||||
PatchingInputAccessor(
|
||||
ref<InputAccessor> next,
|
||||
|
@ -29,7 +29,7 @@ struct PatchingInputAccessor : InputAccessor
|
|||
if (slash == fileName.npos) return;
|
||||
fileName = fileName.substr(slash);
|
||||
debug("found patch for '%s'", fileName);
|
||||
patchesPerFile.emplace(Path(fileName), std::vector<std::string>())
|
||||
patchesPerFile.emplace(fileName, std::vector<std::string>())
|
||||
.first->second.push_back(std::string(contents));
|
||||
};
|
||||
|
||||
|
@ -60,11 +60,11 @@ struct PatchingInputAccessor : InputAccessor
|
|||
}
|
||||
}
|
||||
|
||||
std::string readFile(PathView path) override
|
||||
std::string readFile(const CanonPath & path) override
|
||||
{
|
||||
auto contents = next->readFile(path);
|
||||
|
||||
auto i = patchesPerFile.find((Path) path);
|
||||
auto i = patchesPerFile.find(path);
|
||||
if (i != patchesPerFile.end()) {
|
||||
for (auto & patch : i->second) {
|
||||
auto tempDir = createTempDir();
|
||||
|
@ -84,22 +84,22 @@ struct PatchingInputAccessor : InputAccessor
|
|||
return contents;
|
||||
}
|
||||
|
||||
bool pathExists(PathView path) override
|
||||
bool pathExists(const CanonPath & path) override
|
||||
{
|
||||
return next->pathExists(path);
|
||||
}
|
||||
|
||||
Stat lstat(PathView path) override
|
||||
Stat lstat(const CanonPath & path) override
|
||||
{
|
||||
return next->lstat(path);
|
||||
}
|
||||
|
||||
DirEntries readDirectory(PathView path) override
|
||||
DirEntries readDirectory(const CanonPath & path) override
|
||||
{
|
||||
return next->readDirectory(path);
|
||||
}
|
||||
|
||||
std::string readLink(PathView path) override
|
||||
std::string readLink(const CanonPath & path) override
|
||||
{
|
||||
return next->readLink(path);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue