mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
dfc876531f
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#pragma once
|
|
///@file
|
|
|
|
#include "source-accessor.hh"
|
|
#include "fs-sink.hh"
|
|
#include "util.hh"
|
|
|
|
namespace nix {
|
|
|
|
/**
|
|
* An enumeration of the main ways we can serialize file system
|
|
* objects.
|
|
*/
|
|
enum struct FileIngestionMethod : uint8_t {
|
|
/**
|
|
* Flat-file hashing. Directly ingest the contents of a single file
|
|
*/
|
|
Flat = 0,
|
|
/**
|
|
* Recursive (or NAR) hashing. Serializes the file-system object in
|
|
* Nix Archive format and ingest that.
|
|
*/
|
|
Recursive = 1,
|
|
};
|
|
|
|
/**
|
|
* Dump a serialization of the given file system object.
|
|
*/
|
|
void dumpPath(
|
|
SourceAccessor & accessor, const CanonPath & path,
|
|
Sink & sink,
|
|
FileIngestionMethod method,
|
|
PathFilter & filter = defaultPathFilter);
|
|
|
|
/**
|
|
* Restore a serialization of the given file system object.
|
|
*
|
|
* @TODO use an arbitrary `ParseSink`.
|
|
*/
|
|
void restorePath(
|
|
const Path & path,
|
|
Source & source,
|
|
FileIngestionMethod method);
|
|
|
|
/**
|
|
* Compute the hash of the given file system object according to the
|
|
* given method.
|
|
*
|
|
* The hash is defined as (essentially) hashString(ht, dumpPath(path)).
|
|
*/
|
|
HashResult hashPath(
|
|
SourceAccessor & accessor, const CanonPath & path,
|
|
FileIngestionMethod method, HashAlgorithm ht,
|
|
PathFilter & filter = defaultPathFilter);
|
|
|
|
}
|