1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 07:33:16 +02:00

use CanonPath in fs-sink and its derivatives

This commit is contained in:
siddhantCodes 2024-06-30 19:03:15 +05:30
parent 32e6cc64b5
commit 72bb530141
12 changed files with 73 additions and 79 deletions

View file

@ -28,17 +28,17 @@ struct FileSystemObjectSink
{
virtual ~FileSystemObjectSink() = default;
virtual void createDirectory(const Path & path) = 0;
virtual void createDirectory(const CanonPath & path) = 0;
/**
* This function in general is no re-entrant. Only one file can be
* written at a time.
*/
virtual void createRegularFile(
const Path & path,
const CanonPath & path,
std::function<void(CreateRegularFileSink &)>) = 0;
virtual void createSymlink(const Path & path, const std::string & target) = 0;
virtual void createSymlink(const CanonPath & path, const std::string & target) = 0;
};
/**
@ -46,17 +46,17 @@ struct FileSystemObjectSink
*/
void copyRecursive(
SourceAccessor & accessor, const CanonPath & sourcePath,
FileSystemObjectSink & sink, const Path & destPath);
FileSystemObjectSink & sink, const CanonPath & destPath);
/**
* Ignore everything and do nothing
*/
struct NullFileSystemObjectSink : FileSystemObjectSink
{
void createDirectory(const Path & path) override { }
void createSymlink(const Path & path, const std::string & target) override { }
void createDirectory(const CanonPath & path) override { }
void createSymlink(const CanonPath & path, const std::string & target) override { }
void createRegularFile(
const Path & path,
const CanonPath & path,
std::function<void(CreateRegularFileSink &)>) override;
};
@ -65,15 +65,15 @@ struct NullFileSystemObjectSink : FileSystemObjectSink
*/
struct RestoreSink : FileSystemObjectSink
{
Path dstPath;
std::filesystem::path dstPath;
void createDirectory(const Path & path) override;
void createDirectory(const CanonPath & path) override;
void createRegularFile(
const Path & path,
const CanonPath & path,
std::function<void(CreateRegularFileSink &)>) override;
void createSymlink(const Path & path, const std::string & target) override;
void createSymlink(const CanonPath & path, const std::string & target) override;
};
/**
@ -88,18 +88,18 @@ struct RegularFileSink : FileSystemObjectSink
RegularFileSink(Sink & sink) : sink(sink) { }
void createDirectory(const Path & path) override
void createDirectory(const CanonPath & path) override
{
regular = false;
}
void createSymlink(const Path & path, const std::string & target) override
void createSymlink(const CanonPath & path, const std::string & target) override
{
regular = false;
}
void createRegularFile(
const Path & path,
const CanonPath & path,
std::function<void(CreateRegularFileSink &)>) override;
};