Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
tarfile.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include "
nix/util/compression-algo.hh
"
5
6
#include <exception>
7
8
struct
archive;
9
10
namespace
nix {
11
12
struct
Source
;
13
struct
Sink
;
14
class
CanonPath
;
15
16
struct
TarArchive
17
{
18
::archive * archive;
19
Source
* source;
20
std::vector<unsigned char> buffer;
21
/* Exception encountered when reading the source. */
22
std::exception_ptr readException;
23
24
void
check(
int
err,
const
std::string & reason =
"failed to extract archive (%s)"
,
bool
warningsAreFatal =
true
);
25
26
explicit
TarArchive(
const
std::filesystem::path & path);
27
35
TarArchive(
Source
& source,
bool
raw =
false
, std::optional<CompressionAlgo> compressionMethod = std::nullopt);
36
TarArchive(
const
TarArchive &) =
delete
;
37
TarArchive & operator=(
const
TarArchive &) =
delete
;
38
TarArchive(TarArchive &&) =
delete
;
39
TarArchive & operator=(TarArchive &&) =
delete
;
40
~TarArchive();
41
42
void
close();
43
};
44
45
void
unpackTarfile(
const
std::filesystem::path & tarFile,
const
std::filesystem::path & destDir);
46
57
struct
TarSink
58
{
59
virtual
~TarSink
();
60
61
virtual
void
createDirectory(
const
CanonPath
& path) = 0;
62
63
virtual
void
createRegularFile(
const
CanonPath
& path,
bool
isExecutable,
fun
<
void
(
Sink
&)> callback) = 0;
64
65
virtual
void
createSymlink(
const
CanonPath
& path,
const
std::string & target) = 0;
66
71
virtual
void
createHardlink
(
const
CanonPath
& path,
const
CanonPath
& target) = 0;
72
};
73
77
struct
NullTarSink :
TarSink
78
{
79
NullTarSink() {}
80
81
~NullTarSink();
82
83
void
createDirectory(
const
CanonPath
& path)
override
{}
84
85
void
createRegularFile(
const
CanonPath
& path,
bool
isExecutable,
fun
<
void
(
Sink
&)> callback)
override
;
86
87
void
createSymlink(
const
CanonPath
& path,
const
std::string & target)
override
{}
88
89
void
createHardlink
(
const
CanonPath
& path,
const
CanonPath
& target)
override
{}
90
};
91
92
time_t unpackTarfileToSink(TarArchive & archive, TarSink & parseSink);
93
94
}
// namespace nix
nix::CanonPath
Definition
canon-path.hh:50
nix::fun
Definition
fun.hh:19
compression-algo.hh
nix::NullTarSink::createHardlink
void createHardlink(const CanonPath &path, const CanonPath &target) override
Definition
tarfile.hh:89
nix::Sink
Definition
serialise.hh:18
nix::Source
Definition
serialise.hh:95
nix::TarSink
Definition
tarfile.hh:58
nix::TarSink::createHardlink
virtual void createHardlink(const CanonPath &path, const CanonPath &target)=0
libutil
include
nix
util
tarfile.hh
Generated by
1.18.0