mirror of
https://github.com/NixOS/nix
synced 2025-07-06 17:31:47 +02:00
Merge FSAccessor into SourceAccessor
This commit is contained in:
parent
581693bdea
commit
1a902f5fa7
25 changed files with 178 additions and 224 deletions
|
@ -10,6 +10,11 @@ SourceAccessor::SourceAccessor()
|
|||
{
|
||||
}
|
||||
|
||||
bool SourceAccessor::pathExists(const CanonPath & path)
|
||||
{
|
||||
return maybeLstat(path).has_value();
|
||||
}
|
||||
|
||||
std::string SourceAccessor::readFile(const CanonPath & path)
|
||||
{
|
||||
StringSink sink;
|
||||
|
|
|
@ -40,7 +40,7 @@ struct SourceAccessor
|
|||
Sink & sink,
|
||||
std::function<void(uint64_t)> sizeCallback = [](uint64_t size){});
|
||||
|
||||
virtual bool pathExists(const CanonPath & path) = 0;
|
||||
virtual bool pathExists(const CanonPath & path);
|
||||
|
||||
enum Type {
|
||||
tRegular, tSymlink, tDirectory,
|
||||
|
@ -57,8 +57,24 @@ struct SourceAccessor
|
|||
struct Stat
|
||||
{
|
||||
Type type = tMisc;
|
||||
//uint64_t fileSize = 0; // regular files only
|
||||
bool isExecutable = false; // regular files only
|
||||
|
||||
/**
|
||||
* For regular files only: the size of the file. Not all
|
||||
* accessors return this since it may be too expensive to
|
||||
* compute.
|
||||
*/
|
||||
std::optional<uint64_t> fileSize;
|
||||
|
||||
/**
|
||||
* For regular files only: whether this is an executable.
|
||||
*/
|
||||
bool isExecutable = false;
|
||||
|
||||
/**
|
||||
* For regular files only: the position of the contents of this
|
||||
* file in the NAR. Only returned by NAR accessors.
|
||||
*/
|
||||
std::optional<uint64_t> narOffset;
|
||||
};
|
||||
|
||||
Stat lstat(const CanonPath & path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue