mirror of
https://github.com/NixOS/nix.git
synced 2025-11-30 14:10:59 +01:00
Checkpoint
This commit is contained in:
parent
2d572a250f
commit
c56e17b718
17 changed files with 428 additions and 79 deletions
57
src/libfetchers/input-accessor.hh
Normal file
57
src/libfetchers/input-accessor.hh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include "ref.hh"
|
||||
#include "types.hh"
|
||||
#include "archive.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
struct InputAccessor
|
||||
{
|
||||
const size_t number;
|
||||
|
||||
InputAccessor();
|
||||
|
||||
virtual ~InputAccessor()
|
||||
{ }
|
||||
|
||||
virtual std::string readFile(std::string_view path) = 0;
|
||||
|
||||
virtual bool pathExists(std::string_view path) = 0;
|
||||
|
||||
enum Type { tRegular, tSymlink, tDirectory, tMisc };
|
||||
|
||||
struct Stat
|
||||
{
|
||||
Type type = tMisc;
|
||||
//uint64_t fileSize = 0; // regular files only
|
||||
bool isExecutable = false; // regular files only
|
||||
};
|
||||
|
||||
virtual Stat lstat(std::string_view path) = 0;
|
||||
|
||||
typedef std::optional<Type> DirEntry;
|
||||
|
||||
typedef std::map<std::string, DirEntry> DirEntries;
|
||||
|
||||
virtual DirEntries readDirectory(std::string_view path) = 0;
|
||||
|
||||
virtual std::string readLink(std::string_view path) = 0;
|
||||
|
||||
virtual void dumpPath(
|
||||
const Path & path,
|
||||
Sink & sink,
|
||||
PathFilter & filter = defaultPathFilter);
|
||||
};
|
||||
|
||||
ref<InputAccessor> makeFSInputAccessor(const Path & root);
|
||||
|
||||
struct SourcePath
|
||||
{
|
||||
ref<InputAccessor> accessor;
|
||||
Path path;
|
||||
};
|
||||
|
||||
std::ostream & operator << (std::ostream & str, const SourcePath & path);
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue