aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/input-accessor.hh
blob: d8e17c9b17b3ad1984fad3613d35b6093c88e1e2 (plain)
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
32
33
34
35
36
37
#pragma once
///@file


#include <map>
#include <optional>
#include <string>

namespace nix {

struct InputAccessor
{
    enum Type {
      tRegular, tSymlink, tDirectory,
      /**
        Any other node types that may be encountered on the file system, such as device nodes, sockets, named pipe, and possibly even more exotic things.

        Responsible for `"unknown"` from `builtins.readFileType "/dev/null"`.

        Unlike `DT_UNKNOWN`, this must not be used for deferring the lookup of types.
      */
      tMisc
    };

    struct Stat
    {
        Type type = tMisc;
        //uint64_t fileSize = 0; // regular files only
        bool isExecutable = false; // regular files only
    };

    typedef std::optional<Type> DirEntry;

    typedef std::map<std::string, DirEntry> DirEntries;
};

}