2012-07-18 18:59:03 +00:00
|
|
|
#pragma once
|
2003-07-14 10:23:11 +00:00
|
|
|
|
2009-03-28 20:51:33 +00:00
|
|
|
#include "hash.hh"
|
2021-10-04 11:47:38 +00:00
|
|
|
#include "path.hh"
|
2003-07-14 10:23:11 +00:00
|
|
|
|
2006-09-04 21:06:23 +00:00
|
|
|
namespace nix {
|
2003-07-14 10:23:11 +00:00
|
|
|
|
2021-10-04 11:47:38 +00:00
|
|
|
std::pair<StorePathSet, HashResult> scanForReferences(const Path & path, const StorePathSet & refs);
|
2018-03-29 22:56:13 +00:00
|
|
|
|
2021-10-04 11:47:38 +00:00
|
|
|
StorePathSet scanForReferences(Sink & toTee, const Path & path, const StorePathSet & refs);
|
2020-08-07 19:09:26 +00:00
|
|
|
|
2021-10-04 12:29:42 +00:00
|
|
|
class RefScanSink : public Sink
|
|
|
|
{
|
|
|
|
StringSet hashes;
|
|
|
|
StringSet seen;
|
|
|
|
|
|
|
|
std::string tail;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
RefScanSink(StringSet && hashes) : hashes(hashes)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
StringSet & getResult()
|
|
|
|
{ return seen; }
|
|
|
|
|
|
|
|
void operator () (std::string_view data) override;
|
|
|
|
};
|
|
|
|
|
2022-11-04 13:19:31 +00:00
|
|
|
class PathRefScanSink : public RefScanSink
|
|
|
|
{
|
|
|
|
std::map<std::string, StorePath> backMap;
|
|
|
|
|
|
|
|
PathRefScanSink(StringSet && hashes, std::map<std::string, StorePath> && backMap);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static PathRefScanSink fromPaths(const StorePathSet & refs);
|
|
|
|
|
|
|
|
StorePathSet getResultPaths();
|
|
|
|
};
|
|
|
|
|
2018-03-29 22:56:13 +00:00
|
|
|
struct RewritingSink : Sink
|
|
|
|
{
|
|
|
|
std::string from, to, prev;
|
|
|
|
Sink & nextSink;
|
|
|
|
uint64_t pos = 0;
|
|
|
|
|
|
|
|
std::vector<uint64_t> matches;
|
|
|
|
|
|
|
|
RewritingSink(const std::string & from, const std::string & to, Sink & nextSink);
|
|
|
|
|
2020-12-02 13:00:43 +00:00
|
|
|
void operator () (std::string_view data) override;
|
2018-03-29 22:56:13 +00:00
|
|
|
|
|
|
|
void flush();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HashModuloSink : AbstractHashSink
|
|
|
|
{
|
|
|
|
HashSink hashSink;
|
|
|
|
RewritingSink rewritingSink;
|
|
|
|
|
|
|
|
HashModuloSink(HashType ht, const std::string & modulus);
|
|
|
|
|
2020-12-02 13:00:43 +00:00
|
|
|
void operator () (std::string_view data) override;
|
2018-03-29 22:56:13 +00:00
|
|
|
|
|
|
|
HashResult finish() override;
|
|
|
|
};
|
|
|
|
|
2006-09-04 21:06:23 +00:00
|
|
|
}
|