Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
fs-sink.hh
Go to the documentation of this file.
1#pragma once
3
4#include "serialise.hh"
5#include "source-accessor.hh"
6#include "file-system.hh"
7
8namespace nix {
9
16{
17 virtual void isExecutable() = 0;
18
22 virtual void preallocateContents(uint64_t size) { };
23};
24
25
27{
28 virtual ~FileSystemObjectSink() = default;
29
30 virtual void createDirectory(const CanonPath & path) = 0;
31
36 virtual void createRegularFile(
37 const CanonPath & path,
38 std::function<void(CreateRegularFileSink &)>) = 0;
39
40 virtual void createSymlink(const CanonPath & path, const std::string & target) = 0;
41};
42
48{
53 virtual void createHardlink(const CanonPath & path, const CanonPath & target) = 0;
54};
55
59void copyRecursive(
60 SourceAccessor & accessor, const CanonPath & sourcePath,
61 FileSystemObjectSink & sink, const CanonPath & destPath);
62
67{
68 void createDirectory(const CanonPath & path) override { }
69 void createSymlink(const CanonPath & path, const std::string & target) override { }
71 const CanonPath & path,
72 std::function<void(CreateRegularFileSink &)>) override;
73};
74
78struct RestoreSink : FileSystemObjectSink
79{
80 std::filesystem::path dstPath;
81 bool startFsync = false;
82
83 explicit RestoreSink(bool startFsync)
84 : startFsync{startFsync}
85 { }
86
87 void createDirectory(const CanonPath & path) override;
88
90 const CanonPath & path,
91 std::function<void(CreateRegularFileSink &)>) override;
92
93 void createSymlink(const CanonPath & path, const std::string & target) override;
94};
95
101struct RegularFileSink : FileSystemObjectSink
102{
103 bool regular = true;
104 Sink & sink;
105
106 RegularFileSink(Sink & sink) : sink(sink) { }
107
108 void createDirectory(const CanonPath & path) override
109 {
110 regular = false;
111 }
112
113 void createSymlink(const CanonPath & path, const std::string & target) override
114 {
115 regular = false;
116 }
117
119 const CanonPath & path,
120 std::function<void(CreateRegularFileSink &)>) override;
121};
122
123}
Definition canon-path.hh:41
ref< SourceAccessor > accessor
Definition lexer.l:4655
Definition fs-sink.hh:16
virtual void preallocateContents(uint64_t size)
Definition fs-sink.hh:22
Definition fs-sink.hh:48
virtual void createHardlink(const CanonPath &path, const CanonPath &target)=0
Definition fs-sink.hh:27
virtual void createRegularFile(const CanonPath &path, std::function< void(CreateRegularFileSink &)>)=0
Definition fs-sink.hh:67
void createRegularFile(const CanonPath &path, std::function< void(CreateRegularFileSink &)>) override
Definition fs-sink.cc:182
void createRegularFile(const CanonPath &path, std::function< void(CreateRegularFileSink &)>) override
Definition fs-sink.cc:167
void createRegularFile(const CanonPath &path, std::function< void(CreateRegularFileSink &)>) override
Definition fs-sink.cc:107
Definition serialise.hh:20
Definition source-accessor.hh:42