Skip to content

Commit 5d03ef9

Browse files
committed
PathInputSchema::getAbsPath(): Return std::filesystem::path
1 parent 521667e commit 5d03ef9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libfetchers/path.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct PathInputScheme : InputScheme
9191
std::string_view contents,
9292
std::optional<std::string> commitMsg) const override
9393
{
94-
writeFile((CanonPath(getAbsPath(input)) / path).abs(), contents);
94+
writeFile(getAbsPath(input) / path.rel(), contents);
9595
}
9696

9797
std::optional<std::string> isRelative(const Input & input) const override
@@ -108,12 +108,12 @@ struct PathInputScheme : InputScheme
108108
return (bool) input.getNarHash();
109109
}
110110

111-
CanonPath getAbsPath(const Input & input) const
111+
std::filesystem::path getAbsPath(const Input & input) const
112112
{
113113
auto path = getStrAttr(input.attrs, "path");
114114

115-
if (path[0] == '/')
116-
return CanonPath(path);
115+
if (isAbsolute(path))
116+
return canonPath(path);
117117

118118
throw Error("cannot fetch input '%s' because it uses a relative path", input.to_string());
119119
}
@@ -128,7 +128,7 @@ struct PathInputScheme : InputScheme
128128
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying '%s' to the store", absPath));
129129

130130
// FIXME: check whether access to 'path' is allowed.
131-
auto storePath = store->maybeParseStorePath(absPath.abs());
131+
auto storePath = store->maybeParseStorePath(absPath.string());
132132

133133
if (storePath)
134134
store->addTempRoot(*storePath);
@@ -137,7 +137,7 @@ struct PathInputScheme : InputScheme
137137
if (!storePath || storePath->name() != "source" || !store->isValidPath(*storePath)) {
138138
// FIXME: try to substitute storePath.
139139
auto src = sinkToSource([&](Sink & sink) {
140-
mtime = dumpPathAndGetMtime(absPath.abs(), sink, defaultPathFilter);
140+
mtime = dumpPathAndGetMtime(absPath.string(), sink, defaultPathFilter);
141141
});
142142
storePath = store->addToStoreFromDump(*src, "source");
143143
}
@@ -159,7 +159,7 @@ struct PathInputScheme : InputScheme
159159
store object and the subpath. */
160160
auto path = getAbsPath(input);
161161
try {
162-
auto [storePath, subPath] = store->toStorePath(path.abs());
162+
auto [storePath, subPath] = store->toStorePath(path.string());
163163
auto info = store->queryPathInfo(storePath);
164164
return fmt("path:%s:%s", info->narHash.to_string(HashFormat::Base16, false), subPath);
165165
} catch (Error &) {

0 commit comments

Comments
 (0)