#include <source-path.hh>
Public Member Functions | |
SourcePath (ref< SourceAccessor > accessor, CanonPath path=CanonPath::root) | |
std::string_view | baseName () const |
SourcePath | parent () const |
std::string | readFile () const |
void | readFile (Sink &sink, std::function< void(uint64_t)> sizeCallback=[](uint64_t size){}) const |
bool | pathExists () const |
SourceAccessor::Stat | lstat () const |
std::optional< SourceAccessor::Stat > | maybeLstat () const |
SourceAccessor::DirEntries | readDirectory () const |
std::string | readLink () const |
void | dumpPath (Sink &sink, PathFilter &filter=defaultPathFilter) const |
std::optional< std::filesystem::path > | getPhysicalPath () const |
std::string | to_string () const |
SourcePath | operator/ (const CanonPath &x) const |
SourcePath | operator/ (std::string_view c) const |
bool | operator== (const SourcePath &x) const noexcept |
std::strong_ordering | operator<=> (const SourcePath &x) const noexcept |
SourcePath | resolveSymlinks (SymlinkResolution mode=SymlinkResolution::Full) const |
Public Attributes | |
ref< SourceAccessor > | accessor |
CanonPath | path |
Friends | |
class | std::hash< nix::SourcePath > |
An abstraction for accessing source files during evaluation. Currently, it's just a wrapper around CanonPath
that accesses files in the regular filesystem, but in the future it will support fetching files in other ways.
void nix::SourcePath::dumpPath | ( | Sink & | sink, |
PathFilter & | filter = defaultPathFilter ) const |
Dump this SourcePath
to sink
as a NAR archive.
std::optional< std::filesystem::path > nix::SourcePath::getPhysicalPath | ( | ) | const |
Return the location of this path in the "real" filesystem, if it has a physical location.
SourceAccessor::Stat nix::SourcePath::lstat | ( | ) | const |
Return stats about this SourcePath
, or throw an exception if it doesn't exist.
std::optional< SourceAccessor::Stat > nix::SourcePath::maybeLstat | ( | ) | const |
Return stats about this SourcePath
, or std::nullopt if it doesn't exist.
SourcePath nix::SourcePath::operator/ | ( | const CanonPath & | x | ) | const |
Append a CanonPath
to this path.
SourcePath nix::SourcePath::operator/ | ( | std::string_view | c | ) | 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 nix::SourcePath::parent | ( | ) | const |
Construct the parent of this SourcePath
. Aborts if this
denotes the root.
bool nix::SourcePath::pathExists | ( | ) | const |
Return whether this SourcePath
denotes a file (of any type) that exists
SourceAccessor::DirEntries nix::SourcePath::readDirectory | ( | ) | const |
If this SourcePath
denotes a directory (not a symlink), return its directory entries; otherwise throw an error.
std::string nix::SourcePath::readFile | ( | ) | const |
If this SourcePath
denotes a regular file (not a symlink), return its contents; otherwise throw an error.
std::string nix::SourcePath::readLink | ( | ) | const |
If this SourcePath
denotes a symlink, return its target; otherwise throw an error.
|
inline |
Convenience wrapper around SourceAccessor::resolveSymlinks()
.