![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <source-accessor.hh>
Classes | |
| struct | Stat |
Public Types | |
| enum | Type { tRegular , tSymlink , tDirectory , tChar , tBlock , tSocket , tFifo , tUnknown } |
| typedef std::optional< Type > | DirEntry |
| typedef std::map< std::string, DirEntry > | DirEntries |
Public Member Functions | |
| std::string | readFile (const CanonPath &path) |
| virtual void | readFile (const CanonPath &path, Sink &sink, fun< void(uint64_t)> sizeCallback=[](uint64_t size) {})=0 |
| virtual bool | pathExists (const CanonPath &path) |
Check whether a file exists at path. | |
| virtual Stat | lstat (const CanonPath &path) |
| virtual std::optional< Stat > | maybeLstat (const CanonPath &path)=0 |
| virtual DirEntries | readDirectory (const CanonPath &path)=0 |
| virtual void | readDirectory (const CanonPath &dirPath, std::function< void(SourceAccessor &subdirAccessor, const CanonPath &subdirRelPath)> callback) |
| virtual std::string | readLink (const CanonPath &path)=0 |
| virtual void | dumpPath (const CanonPath &path, Sink &sink, PathFilter &filter=defaultPathFilter) |
| Hash | hashPath (const CanonPath &path, PathFilter &filter=defaultPathFilter, HashAlgorithm ha=HashAlgorithm::SHA256) |
| virtual std::optional< std::filesystem::path > | getPhysicalPath (const CanonPath &path) |
| bool | operator== (const SourceAccessor &x) const |
| auto | operator<=> (const SourceAccessor &x) const |
| void | setPathDisplay (std::string displayPrefix, std::string displaySuffix="") |
| virtual std::string | showPath (const CanonPath &path) |
| Render a human-readable representation of the accessor + path beneath it. | |
| CanonPath | resolveSymlinks (const CanonPath &path, SymlinkResolution mode=SymlinkResolution::Full) |
| virtual std::pair< CanonPath, std::optional< std::string > > | getFingerprint (const CanonPath &path) |
| virtual std::optional< time_t > | getLastModified () |
| virtual void | invalidateCache () |
Public Attributes | |
| const size_t | number |
| std::string | displayPrefix |
| std::string | displaySuffix |
| std::optional< std::string > | fingerprint |
A read-only filesystem abstraction. This is used by the Nix evaluator and elsewhere for accessing sources in various filesystem-like entities (such as the real filesystem, tarballs or Git repositories).
|
inlinevirtual |
Return the fingerprint for path. This is usually the fingerprint of the current accessor, but for composite accessors (like MountedSourceAccessor), we want to return the fingerprint of the "inner" accessor if the current one lacks a fingerprint.
So this method is intended to return the most-outer accessor that has a fingerprint for path. It also returns the path that path corresponds to in that accessor.
For example: in a MountedSourceAccessor that has /nix/store/foo mounted, getFingerprint("/nix/store/foo/bar") will return the path /bar and the fingerprint of the /nix/store/foo accessor.
Reimplemented in nix::FilteringSourceAccessor.
|
inlinevirtual |
Return the maximum last-modified time of the files in this tree, if available.
|
inlinevirtual |
Return a corresponding path in the root filesystem, if possible. This is only possible for filesystems that are materialized in the root filesystem.
Reimplemented in nix::FilteringSourceAccessor.
|
inlinevirtual |
Drop any cached state that could go stale across external filesystem mutation (e.g. cached directory fds).
Reimplemented in nix::FilteringSourceAccessor.
|
virtual |
Check whether a file exists at path.
Reimplemented in nix::FilteringSourceAccessor, nix::GitSourceAccessor, and nix::MemorySourceAccessor.
|
inlinevirtual |
Variation of readDirectory that receives a SourceAccessor possibly scoped to dirPath. Primary meant for recursive traversal functions that would benefit from *at-style syscalls relative to a particular directory.
| callback | Caller-provided function invoked with a maximally deeply scoped SourceAccessor and the path that would have to be prepended to each path relative to dirPath to access a particular file with it. |
|
pure virtual |
Implemented in nix::FilteringSourceAccessor, nix::GitSourceAccessor, nix::MemorySourceAccessor, and nix::RemoteFSAccessor.
| std::string nix::SourceAccessor::readFile | ( | const CanonPath & | path | ) |
Return the contents of a file as a string.
|
pure virtual |
Write the contents of a file as a sink. sizeCallback must be called with the size of the file before any data is written to the sink.
Implemented in nix::FilteringSourceAccessor, nix::GitSourceAccessor, nix::MemorySourceAccessor, and nix::RemoteFSAccessor.
| CanonPath nix::SourceAccessor::resolveSymlinks | ( | const CanonPath & | path, |
| SymlinkResolution | mode = SymlinkResolution::Full ) |
Resolve any symlinks in path according to the given resolution mode.
| mode | might only be a temporary solution for this. See the discussion in https://github.com/NixOS/nix/pull/9985. |
|
virtual |
Render a human-readable representation of the accessor + path beneath it.
Reimplemented in nix::FilteringSourceAccessor.
| std::optional<std::string> nix::SourceAccessor::fingerprint |
A string that uniquely represents the contents of this accessor. This is used for caching lookups (see fetchToStore()).