4 #include "serialise.hh"
10 /* dumpPath creates a Nix archive of the specified path. The format
13 IF path points to a REGULAR FILE:
16 , ("contents", contents(path))
19 IF path points to a DIRECTORY:
21 [ ("type", "directory")
22 , ("entries", concat(map(f, sort(entries(path)))))
26 , ("file", dump(path + "/" + fn))
31 attrs(as) = concat(map(attr, as)) + encN(0)
32 attrs((a, b)) = encS(a) + encS(b)
34 encS(s) = encN(len(s)) + s + (padding until next 64-bit boundary)
36 encN(n) = 64-bit little-endian encoding of n.
38 contents(path) = the contents of a regular file.
40 sort(strings) = lexicographic sort by 8-bit value (strcmp).
42 entries(path) = the entries of a directory, without `.' and
45 `+' denotes string concatenation. */
49 virtual ~PathFilter() { }
50 virtual bool operator () (const Path
& path
) { return true; }
53 extern PathFilter defaultPathFilter
;
55 void dumpPath(const Path
& path
, Sink
& sink
,
56 PathFilter
& filter
= defaultPathFilter
);
60 virtual void createDirectory(const Path
& path
) { };
62 virtual void createRegularFile(const Path
& path
) { };
63 virtual void isExecutable() { };
64 virtual void preallocateContents(unsigned long long size
) { };
65 virtual void receiveContents(unsigned char * data
, unsigned int len
) { };
67 virtual void createSymlink(const Path
& path
, const string
& target
) { };
70 void parseDump(ParseSink
& sink
, Source
& source
);
72 void restorePath(const Path
& path
, Source
& source
);