2016-02-25 16:43:19 +00:00
|
|
|
#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
|
|
|
|
{
|
2017-12-06 21:44:08 +00:00
|
|
|
Type type = tMissing;
|
|
|
|
uint64_t fileSize = 0; // regular files only
|
|
|
|
bool isExecutable = false; // regular files only
|
|
|
|
uint64_t narOffset = 0; // regular files only
|
2016-02-25 16:43:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|