nix-super/src/libstore/remote-fs-accessor.hh

44 lines
976 B
C++
Raw Normal View History

#pragma once
///@file
2023-11-01 18:09:28 +02:00
#include "source-accessor.hh"
#include "ref.hh"
#include "store-api.hh"
namespace nix {
2023-11-01 18:09:28 +02:00
class RemoteFSAccessor : public SourceAccessor
{
ref<Store> store;
2023-11-01 18:09:28 +02:00
std::map<std::string, ref<SourceAccessor>> nars;
bool requireValidPath;
Path cacheDir;
2023-11-01 18:09:28 +02:00
std::pair<ref<SourceAccessor>, CanonPath> fetch(const CanonPath & path);
friend class BinaryCacheStore;
Path makeCacheFile(std::string_view hashPart, const std::string & ext);
2023-11-01 18:09:28 +02:00
ref<SourceAccessor> addToCache(std::string_view hashPart, std::string && nar);
public:
RemoteFSAccessor(ref<Store> store,
2023-11-01 18:09:28 +02:00
bool requireValidPath = true,
const /* FIXME: use std::optional */ Path & cacheDir = "");
2023-11-01 18:09:28 +02:00
std::optional<Stat> maybeLstat(const CanonPath & path) override;
2023-11-01 18:09:28 +02:00
DirEntries readDirectory(const CanonPath & path) override;
2023-11-01 18:09:28 +02:00
std::string readFile(const CanonPath & path) override;
2023-11-01 18:09:28 +02:00
std::string readLink(const CanonPath & path) override;
};
}