aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/archive.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-03 21:02:28 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-03 21:02:28 +0000
commit062533f7cdb74026096ca8c7d5b6e393893d59ef (patch)
treecca64de7b3581072d1d9ecd11a31b053de68f6d5 /src/libutil/archive.hh
parentd92d4f85a5c8a2a2385c084500a8b6bd54b54e6c (diff)
parenta2842588ec86a0f488a385d453eda86e1f52f05a (diff)
Merge remote-tracking branch 'upstream/master' into path-info-header
Diffstat (limited to 'src/libutil/archive.hh')
-rw-r--r--src/libutil/archive.hh28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/libutil/archive.hh b/src/libutil/archive.hh
index 768fe2536..5665732d2 100644
--- a/src/libutil/archive.hh
+++ b/src/libutil/archive.hh
@@ -57,17 +57,35 @@ struct ParseSink
virtual void createRegularFile(const Path & path) { };
virtual void isExecutable() { };
- virtual void preallocateContents(unsigned long long size) { };
- virtual void receiveContents(unsigned char * data, unsigned int len) { };
+ virtual void preallocateContents(uint64_t size) { };
+ virtual void receiveContents(unsigned char * data, size_t len) { };
virtual void createSymlink(const Path & path, const string & target) { };
};
-struct TeeSink : ParseSink
+/* If the NAR archive contains a single file at top-level, then save
+ the contents of the file to `s'. Otherwise barf. */
+struct RetrieveRegularNARSink : ParseSink
{
- TeeSource source;
+ bool regular = true;
+ Sink & sink;
- TeeSink(Source & source) : source(source) { }
+ RetrieveRegularNARSink(Sink & sink) : sink(sink) { }
+
+ void createDirectory(const Path & path)
+ {
+ regular = false;
+ }
+
+ void receiveContents(unsigned char * data, size_t len)
+ {
+ sink(data, len);
+ }
+
+ void createSymlink(const Path & path, const string & target)
+ {
+ regular = false;
+ }
};
void parseDump(ParseSink & sink, Source & source);