Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
archive.hh
Go to the documentation of this file.
1#pragma once
3
10
11
12namespace nix {
13
14
63WireFormatGenerator dumpPath(Path path, PathFilter & filter);
64WireFormatGenerator dumpPath(Path path);
65
69WireFormatGenerator dumpPathAndGetMtime(Path path, time_t & mtime);
70
75struct PreparedDump
76{
77 const Path rootPath;
78
79 explicit PreparedDump(Path rootPath) : rootPath(std::move(rootPath)) {}
80
81 virtual ~PreparedDump() = default;
82
89 virtual WireFormatGenerator dump() const = 0;
90};
91
92box_ptr<PreparedDump> prepareDump(Path path);
93box_ptr<PreparedDump> prepareDump(Path path, PathFilter & filter);
94
100WireFormatGenerator dumpString(std::string_view s);
101
110{
114 struct FileHandle
115 {
116 FileHandle() {}
117 FileHandle(FileHandle const &) = delete;
118 FileHandle & operator=(FileHandle &) = delete;
119
121 virtual void receiveContents(std::string_view data) = 0;
122
127 virtual void close() = 0;
128
129 virtual ~FileHandle() = default;
130 };
131
132 virtual ~NARParseVisitor() = default;
133
134 virtual box_ptr<NARParseVisitor> createDirectory(const std::string & name) = 0;
135
140 virtual box_ptr<FileHandle> createRegularFile(const std::string & name, uint64_t size, bool executable) = 0;
141
142 virtual void createSymlink(const std::string & name, const std::string & target) = 0;
143};
144
145namespace nar {
146
147struct File;
148struct Symlink;
149struct Directory;
150using Entry = std::variant<File, Symlink, Directory>;
151
152struct File
153{
154 bool executable;
155 uint64_t size;
156 Generator<Bytes> contents;
157};
158
160{
161 Path target;
162};
163
168
169WireFormatGenerator dump(Entry nar);
170
176Generator<Entry> parse(Source & source);
177}
178
179namespace nar_index {
180
181struct File;
182struct Symlink;
183struct Directory;
184using Entry = std::variant<File, Symlink, Directory>;
185
186struct File
187{
188 bool executable;
189 uint64_t offset, size;
190};
191
193{
194 Path target;
195};
196
198{
199 std::map<std::string, Entry> contents;
200};
201
202Entry create(Source & source);
203kj::Promise<Result<Entry>> create(AsyncInputStream & source);
204
205}
206
207void parseDump(NARParseVisitor & sink, Source & source);
208kj::Promise<Result<void>> parseDump(NARParseVisitor & sink, AsyncInputStream & source);
209
210void restorePath(const Path & path, Source & source);
211kj::Promise<Result<void>> restorePath(const Path & path, AsyncInputStream & source);
212
216WireFormatGenerator copyNAR(Source & source);
218
219
220inline constexpr std::string_view narVersionMagic1 = "nix-archive-1";
221
222inline constexpr std::string_view caseHackSuffix = "~nix~case~hack~";
223
224
225}
Definition async-io.hh:19
Definition box_ptr.hh:16
std::function< bool(const Path &path)> PathFilter
Definition file-system.hh:318
Definition generator.hh:236
virtual void receiveContents(std::string_view data)=0
Definition archive.hh:110
virtual box_ptr< FileHandle > createRegularFile(const std::string &name, uint64_t size, bool executable)=0
virtual WireFormatGenerator dump() const =0
Definition serialise.hh:66
Definition archive.hh:165
Definition archive.hh:153
Definition archive.hh:198
Definition archive.hh:187
std::string Path
Definition types.hh:28