about summary refs log tree commit diff
path: root/src/libstore/fs-accessor.hh
blob: f703e1d154041bf22bd7c96731b827e050de11f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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 = tMissing;
        uint64_t fileSize = 0; // regular files only
        bool isExecutable = false; // regular files only
        uint64_t narOffset = 0; // 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;
};

}