Fix resolveExprPath()

This commit is contained in:
Eelco Dolstra 2022-05-09 14:28:47 +02:00
parent 53869fbd42
commit e89d3e0edf
3 changed files with 10 additions and 5 deletions

View file

@ -699,11 +699,8 @@ SourcePath resolveExprPath(const SourcePath & path)
#endif
// FIXME
auto path2 = path.path + "/default.nix";
if (path.pathExists())
return {path.accessor, path2};
return path;
auto path2 = path.append("/default.nix");
return path2.pathExists() ? path2 : path;
}

View file

@ -227,6 +227,12 @@ std::ostream & operator << (std::ostream & str, const SourcePath & path)
return str;
}
SourcePath SourcePath::append(std::string_view s) const
{
// FIXME: canonicalize?
return {accessor, path + s};
}
struct MemoryInputAccessorImpl : MemoryInputAccessor
{
std::map<Path, std::string> files;

View file

@ -92,6 +92,8 @@ struct SourcePath
{ return accessor.dumpPath(path, sink, filter); }
std::string to_string() const;
SourcePath append(std::string_view s) const;
};
std::ostream & operator << (std::ostream & str, const SourcePath & path);