mirror of
https://github.com/NixOS/nix
synced 2025-07-06 13:21:47 +02:00
CanonPath, SourcePath: Change operator + to /
This is less confusing and makes it more similar to std::filesystem::path.
This commit is contained in:
parent
6ec08b85f6
commit
a6737b7e17
23 changed files with 48 additions and 47 deletions
|
@ -77,20 +77,20 @@ void SourceAccessor::dumpPath(
|
|||
std::string name(i.first);
|
||||
size_t pos = i.first.find(caseHackSuffix);
|
||||
if (pos != std::string::npos) {
|
||||
debug("removing case hack suffix from '%s'", path + i.first);
|
||||
debug("removing case hack suffix from '%s'", path / i.first);
|
||||
name.erase(pos);
|
||||
}
|
||||
if (!unhacked.emplace(name, i.first).second)
|
||||
throw Error("file name collision in between '%s' and '%s'",
|
||||
(path + unhacked[name]),
|
||||
(path + i.first));
|
||||
(path / unhacked[name]),
|
||||
(path / i.first));
|
||||
} else
|
||||
unhacked.emplace(i.first, i.first);
|
||||
|
||||
for (auto & i : unhacked)
|
||||
if (filter((path + i.first).abs())) {
|
||||
if (filter((path / i.first).abs())) {
|
||||
sink << "entry" << "(" << "name" << i.first << "node";
|
||||
dump(path + i.second);
|
||||
dump(path / i.second);
|
||||
sink << ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ void CanonPath::extend(const CanonPath & x)
|
|||
path += x.abs();
|
||||
}
|
||||
|
||||
CanonPath CanonPath::operator + (const CanonPath & x) const
|
||||
CanonPath CanonPath::operator / (const CanonPath & x) const
|
||||
{
|
||||
auto res = *this;
|
||||
res.extend(x);
|
||||
|
@ -78,7 +78,7 @@ void CanonPath::push(std::string_view c)
|
|||
path += c;
|
||||
}
|
||||
|
||||
CanonPath CanonPath::operator + (std::string_view c) const
|
||||
CanonPath CanonPath::operator / (std::string_view c) const
|
||||
{
|
||||
auto res = *this;
|
||||
res.push(c);
|
||||
|
|
|
@ -190,14 +190,14 @@ public:
|
|||
/**
|
||||
* Concatenate two paths.
|
||||
*/
|
||||
CanonPath operator + (const CanonPath & x) const;
|
||||
CanonPath operator / (const CanonPath & x) const;
|
||||
|
||||
/**
|
||||
* Add a path component to this one. It must not contain any slashes.
|
||||
*/
|
||||
void push(std::string_view c);
|
||||
|
||||
CanonPath operator + (std::string_view c) const;
|
||||
CanonPath operator / (std::string_view c) const;
|
||||
|
||||
/**
|
||||
* Check whether access to this path is allowed, which is the case
|
||||
|
|
|
@ -34,7 +34,7 @@ void copyRecursive(
|
|||
sink.createDirectory(to);
|
||||
for (auto & [name, _] : accessor.readDirectory(from)) {
|
||||
copyRecursive(
|
||||
accessor, from + name,
|
||||
accessor, from / name,
|
||||
sink, to + "/" + name);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ Mode dump(
|
|||
{
|
||||
Tree entries;
|
||||
for (auto & [name, _] : accessor.readDirectory(path)) {
|
||||
auto child = path + name;
|
||||
auto child = path / name;
|
||||
if (!filter(child.abs())) continue;
|
||||
|
||||
auto entry = hook(child);
|
||||
|
|
|
@ -41,11 +41,11 @@ std::optional<CanonPath> SourcePath::getPhysicalPath() const
|
|||
std::string SourcePath::to_string() const
|
||||
{ return accessor->showPath(path); }
|
||||
|
||||
SourcePath SourcePath::operator+(const CanonPath & x) const
|
||||
{ return {accessor, path + x}; }
|
||||
SourcePath SourcePath::operator / (const CanonPath & x) const
|
||||
{ return {accessor, path / x}; }
|
||||
|
||||
SourcePath SourcePath::operator+(std::string_view c) const
|
||||
{ return {accessor, path + c}; }
|
||||
SourcePath SourcePath::operator / (std::string_view c) const
|
||||
{ return {accessor, path / c}; }
|
||||
|
||||
bool SourcePath::operator==(const SourcePath & x) const
|
||||
{
|
||||
|
|
|
@ -89,14 +89,15 @@ struct SourcePath
|
|||
/**
|
||||
* Append a `CanonPath` to this path.
|
||||
*/
|
||||
SourcePath operator + (const CanonPath & x) const;
|
||||
SourcePath operator / (const CanonPath & x) const;
|
||||
|
||||
/**
|
||||
* Append a single component `c` to this path. `c` must not
|
||||
* contain a slash. A slash is implicitly added between this path
|
||||
* and `c`.
|
||||
*/
|
||||
SourcePath operator+(std::string_view c) const;
|
||||
SourcePath operator / (std::string_view c) const;
|
||||
|
||||
bool operator==(const SourcePath & x) const;
|
||||
bool operator!=(const SourcePath & x) const;
|
||||
bool operator<(const SourcePath & x) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue