mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Add ForwardingSourceAccessor
This commit is contained in:
parent
76b9be3782
commit
a69b99ade0
2 changed files with 58 additions and 0 deletions
57
src/libutil/include/nix/util/forwarding-source-accessor.hh
Normal file
57
src/libutil/include/nix/util/forwarding-source-accessor.hh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include "source-accessor.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
/**
|
||||
* A source accessor that just forwards every operation to another
|
||||
* accessor. This is not useful in itself but can be used as a
|
||||
* superclass for accessors that do change some operations.
|
||||
*/
|
||||
struct ForwardingSourceAccessor : SourceAccessor
|
||||
{
|
||||
ref<SourceAccessor> next;
|
||||
|
||||
ForwardingSourceAccessor(ref<SourceAccessor> next)
|
||||
: next(next)
|
||||
{
|
||||
}
|
||||
|
||||
std::string readFile(const CanonPath & path) override
|
||||
{
|
||||
return next->readFile(path);
|
||||
}
|
||||
|
||||
void readFile(const CanonPath & path, Sink & sink, std::function<void(uint64_t)> sizeCallback) override
|
||||
{
|
||||
next->readFile(path, sink, sizeCallback);
|
||||
}
|
||||
|
||||
std::optional<Stat> maybeLstat(const CanonPath & path) override
|
||||
{
|
||||
return next->maybeLstat(path);
|
||||
}
|
||||
|
||||
DirEntries readDirectory(const CanonPath & path) override
|
||||
{
|
||||
return next->readDirectory(path);
|
||||
}
|
||||
|
||||
std::string readLink(const CanonPath & path) override
|
||||
{
|
||||
return next->readLink(path);
|
||||
}
|
||||
|
||||
std::string showPath(const CanonPath & path) override
|
||||
{
|
||||
return next->showPath(path);
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> getPhysicalPath(const CanonPath & path) override
|
||||
{
|
||||
return next->getPhysicalPath(path);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ headers = files(
|
|||
'file-system.hh',
|
||||
'finally.hh',
|
||||
'fmt.hh',
|
||||
'forwarding-source-accessor.hh',
|
||||
'fs-sink.hh',
|
||||
'git.hh',
|
||||
'hash.hh',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue