mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Add NAR / Store accessor abstraction
This is primary to allow hydra-queue-runner to extract files like "nix-support/hydra-build-products" from NARs in binary caches.
This commit is contained in:
parent
152b1d6bf9
commit
1042c10fd0
11 changed files with 352 additions and 13 deletions
30
src/libstore/fs-accessor.hh
Normal file
30
src/libstore/fs-accessor.hh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
/* An abstract class for accessing a filesystem-like structure, such
|
||||
as a (possibly remote) Nix store or the contents of a NAR file. */
|
||||
class FSAccessor
|
||||
{
|
||||
public:
|
||||
enum Type { tMissing, tRegular, tSymlink, tDirectory };
|
||||
|
||||
struct Stat
|
||||
{
|
||||
Type type;
|
||||
uint64_t fileSize; // regular files only
|
||||
bool isExecutable; // regular files only
|
||||
};
|
||||
|
||||
virtual Stat stat(const Path & path) = 0;
|
||||
|
||||
virtual StringSet readDirectory(const Path & path) = 0;
|
||||
|
||||
virtual std::string readFile(const Path & path) = 0;
|
||||
|
||||
virtual std::string readLink(const Path & path) = 0;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue