Skip to content

Commit

Permalink
Move ParseSink to its own header
Browse files Browse the repository at this point in the history
We will soon add a new implemenation so the one for NARs in `archive.cc`
isn't the only one.
  • Loading branch information
Ericson2314 committed Sep 8, 2023
1 parent 5473e10 commit 00d8f9a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
17 changes: 1 addition & 16 deletions src/libutil/archive.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "types.hh"
#include "serialise.hh"
#include "fs-sink.hh"


namespace nix {
Expand Down Expand Up @@ -72,22 +73,6 @@ time_t dumpPathAndGetMtime(const Path & path, Sink & sink,
*/
void dumpString(std::string_view s, Sink & sink);

/**
* \todo Fix this API, it sucks.
*/
struct ParseSink
{
virtual void createDirectory(const Path & path) { };

virtual void createRegularFile(const Path & path) { };
virtual void closeRegularFile() { };
virtual void isExecutable() { };
virtual void preallocateContents(uint64_t size) { };
virtual void receiveContents(std::string_view data) { };

virtual void createSymlink(const Path & path, const std::string & target) { };
};

/**
* If the NAR archive contains a single file at top-level, then save
* the contents of the file to `s`. Otherwise barf.
Expand Down
25 changes: 25 additions & 0 deletions src/libutil/fs-sink.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
///@file

#include "types.hh"
#include "serialise.hh"

namespace nix {

/**
* \todo Fix this API, it sucks.
*/
struct ParseSink
{
virtual void createDirectory(const Path & path) { };

virtual void createRegularFile(const Path & path) { };
virtual void closeRegularFile() { };
virtual void isExecutable() { };
virtual void preallocateContents(uint64_t size) { };
virtual void receiveContents(std::string_view data) { };

virtual void createSymlink(const Path & path, const std::string & target) { };
};

}

0 comments on commit 00d8f9a

Please sign in to comment.