2023-10-23 12:05:50 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "source-accessor.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A source accessor that uses the Unix filesystem.
|
|
|
|
*/
|
2023-11-20 19:54:36 +02:00
|
|
|
struct PosixSourceAccessor : virtual SourceAccessor
|
2023-10-23 12:05:50 +03:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The most recent mtime seen by lstat(). This is a hack to
|
|
|
|
* support dumpPathAndGetMtime(). Should remove this eventually.
|
|
|
|
*/
|
|
|
|
time_t mtime = 0;
|
|
|
|
|
|
|
|
void readFile(
|
|
|
|
const CanonPath & path,
|
|
|
|
Sink & sink,
|
|
|
|
std::function<void(uint64_t)> sizeCallback) override;
|
|
|
|
|
|
|
|
bool pathExists(const CanonPath & path) override;
|
|
|
|
|
2023-11-01 16:26:07 +02:00
|
|
|
std::optional<Stat> maybeLstat(const CanonPath & path) override;
|
2023-10-23 12:05:50 +03:00
|
|
|
|
|
|
|
DirEntries readDirectory(const CanonPath & path) override;
|
|
|
|
|
|
|
|
std::string readLink(const CanonPath & path) override;
|
|
|
|
|
|
|
|
std::optional<CanonPath> getPhysicalPath(const CanonPath & path) override;
|
2023-12-06 00:02:59 +02:00
|
|
|
|
2023-12-06 14:55:07 +02:00
|
|
|
private:
|
|
|
|
|
2023-12-06 00:02:59 +02:00
|
|
|
/**
|
|
|
|
* Throw an error if `path` or any of its ancestors are symlinks.
|
|
|
|
*/
|
|
|
|
void assertNoSymlinks(CanonPath path);
|
2023-12-06 14:55:07 +02:00
|
|
|
|
|
|
|
std::optional<struct stat> cachedLstat(const CanonPath & path);
|
2023-10-23 12:05:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|