libutil: remove SourcePath::getPhysicalPath
all files are physical, so this doesn't have to be optional. if it only returns a copy of a member it's not useful either, but performance cost Change-Id: Ib2f935ae247d96418d55bc100e04765dc586528b
This commit is contained in:
committed by
Jade Lovelace
parent
d953e138a2
commit
44255c316d
@@ -168,10 +168,7 @@ static int main_nix_instantiate(std::string programName, Strings argv)
|
||||
if (findFile) {
|
||||
for (auto & i : files) {
|
||||
auto p = evaluator->paths.findFile(i);
|
||||
if (auto fn = p.getPhysicalPath())
|
||||
std::cout << fn->abs() << std::endl;
|
||||
else
|
||||
throw Error("'%s' has no physical path", p);
|
||||
std::cout << p.path.abs() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace nix {
|
||||
|
||||
Strings editorFor(const SourcePath & file, uint32_t line)
|
||||
{
|
||||
auto path = file.getPhysicalPath();
|
||||
if (!path)
|
||||
throw Error("cannot open '%s' in an editor because it has no physical path", file);
|
||||
auto editor = getEnv("EDITOR").value_or("cat");
|
||||
auto args = tokenizeString<Strings>(editor);
|
||||
if (line > 0 && (
|
||||
@@ -18,7 +15,7 @@ Strings editorFor(const SourcePath & file, uint32_t line)
|
||||
editor.find("vim") != std::string::npos ||
|
||||
editor.find("kak") != std::string::npos))
|
||||
args.push_back(fmt("+%d", line));
|
||||
args.push_back(path->abs());
|
||||
args.push_back(file.path.abs());
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,13 +103,6 @@ struct SourcePath
|
||||
PathFilter & filter = defaultPathFilter) const
|
||||
{ sink << nix::dumpPath(path.abs(), filter); }
|
||||
|
||||
/**
|
||||
* Return the location of this path in the "real" filesystem, if
|
||||
* it has a physical location.
|
||||
*/
|
||||
std::optional<CanonPath> getPhysicalPath() const
|
||||
{ return path; }
|
||||
|
||||
std::string to_string() const
|
||||
{ return path.abs(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user