Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::SourcePath Struct Reference

#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::StatmaybeLstat () 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< SourceAccessoraccessor
 
CanonPath path
 

Friends

class std::hash< nix::SourcePath >
 

Detailed Description

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.

Member Function Documentation

◆ dumpPath()

void nix::SourcePath::dumpPath ( Sink & sink,
PathFilter & filter = defaultPathFilter ) const

Dump this SourcePath to sink as a NAR archive.

◆ getPhysicalPath()

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.

◆ lstat()

SourceAccessor::Stat nix::SourcePath::lstat ( ) const

Return stats about this SourcePath, or throw an exception if it doesn't exist.

◆ maybeLstat()

std::optional< SourceAccessor::Stat > nix::SourcePath::maybeLstat ( ) const

Return stats about this SourcePath, or std::nullopt if it doesn't exist.

◆ operator/() [1/2]

SourcePath nix::SourcePath::operator/ ( const CanonPath & x) const

Append a CanonPath to this path.

◆ operator/() [2/2]

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.

◆ parent()

SourcePath nix::SourcePath::parent ( ) const

Construct the parent of this SourcePath. Aborts if this denotes the root.

◆ pathExists()

bool nix::SourcePath::pathExists ( ) const

Return whether this SourcePath denotes a file (of any type) that exists

◆ readDirectory()

SourceAccessor::DirEntries nix::SourcePath::readDirectory ( ) const

If this SourcePath denotes a directory (not a symlink), return its directory entries; otherwise throw an error.

◆ readFile()

std::string nix::SourcePath::readFile ( ) const

If this SourcePath denotes a regular file (not a symlink), return its contents; otherwise throw an error.

◆ readLink()

std::string nix::SourcePath::readLink ( ) const

If this SourcePath denotes a symlink, return its target; otherwise throw an error.

◆ resolveSymlinks()

SourcePath nix::SourcePath::resolveSymlinks ( SymlinkResolution mode = SymlinkResolution::Full) const
inline

Convenience wrapper around SourceAccessor::resolveSymlinks().


The documentation for this struct was generated from the following files: