2023-12-18 13:14:42 -08:00
|
|
|
#include "source-path.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
std::string_view SourcePath::baseName() const
|
|
|
|
{ return path.baseName().value_or("source"); }
|
|
|
|
|
|
|
|
SourcePath SourcePath::parent() const
|
|
|
|
{
|
|
|
|
auto p = path.parent();
|
|
|
|
assert(p);
|
|
|
|
return {accessor, std::move(*p)};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string SourcePath::readFile() const
|
|
|
|
{ return accessor->readFile(path); }
|
|
|
|
|
|
|
|
bool SourcePath::pathExists() const
|
|
|
|
{ return accessor->pathExists(path); }
|
|
|
|
|
2024-05-03 12:14:01 +02:00
|
|
|
SourceAccessor::Stat SourcePath::lstat() const
|
2023-12-18 13:14:42 -08:00
|
|
|
{ return accessor->lstat(path); }
|
|
|
|
|
2024-05-03 12:14:01 +02:00
|
|
|
std::optional<SourceAccessor::Stat> SourcePath::maybeLstat() const
|
2023-12-18 13:14:42 -08:00
|
|
|
{ return accessor->maybeLstat(path); }
|
|
|
|
|
2024-05-03 12:14:01 +02:00
|
|
|
SourceAccessor::DirEntries SourcePath::readDirectory() const
|
2023-12-18 13:14:42 -08:00
|
|
|
{ return accessor->readDirectory(path); }
|
|
|
|
|
|
|
|
std::string SourcePath::readLink() const
|
|
|
|
{ return accessor->readLink(path); }
|
|
|
|
|
|
|
|
void SourcePath::dumpPath(
|
|
|
|
Sink & sink,
|
|
|
|
PathFilter & filter) const
|
|
|
|
{ return accessor->dumpPath(path, sink, filter); }
|
|
|
|
|
2024-02-06 16:23:58 -05:00
|
|
|
std::optional<std::filesystem::path> SourcePath::getPhysicalPath() const
|
2023-12-18 13:14:42 -08:00
|
|
|
{ return accessor->getPhysicalPath(path); }
|
|
|
|
|
|
|
|
std::string SourcePath::to_string() const
|
|
|
|
{ return accessor->showPath(path); }
|
|
|
|
|
2024-02-05 15:13:11 +01:00
|
|
|
SourcePath SourcePath::operator / (const CanonPath & x) const
|
|
|
|
{ return {accessor, path / x}; }
|
2023-12-18 13:14:42 -08:00
|
|
|
|
2024-02-05 15:13:11 +01:00
|
|
|
SourcePath SourcePath::operator / (std::string_view c) const
|
|
|
|
{ return {accessor, path / c}; }
|
2023-12-18 13:14:42 -08:00
|
|
|
|
2024-05-16 18:46:38 -04:00
|
|
|
bool SourcePath::operator==(const SourcePath & x) const noexcept
|
2023-12-18 13:14:42 -08:00
|
|
|
{
|
|
|
|
return std::tie(*accessor, path) == std::tie(*x.accessor, x.path);
|
|
|
|
}
|
|
|
|
|
2024-05-16 18:46:38 -04:00
|
|
|
std::strong_ordering SourcePath::operator<=>(const SourcePath & x) const noexcept
|
2023-12-18 13:14:42 -08:00
|
|
|
{
|
2024-05-16 18:46:38 -04:00
|
|
|
return std::tie(*accessor, path) <=> std::tie(*x.accessor, x.path);
|
2023-12-18 13:14:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & str, const SourcePath & path)
|
|
|
|
{
|
|
|
|
str << path.to_string();
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|