35 for (
size_t i = 0; i < n; ++i) {
36 h ^=
static_cast<unsigned char>(data[i]);
37 h *= 1099511628211ULL;
44 std::ifstream in(p, std::ios::binary);
46 while (in.read(buf,
sizeof buf) || in.gcount() > 0)
66 const std::string& deck_path) {
67 namespace fs = std::filesystem;
68 uint64_t h = 1469598103934665603ULL;
70 std::vector<fs::path> files;
72 if (!deck_path.empty() && fs::is_regular_file(deck_path, ec))
73 files.emplace_back(deck_path);
74 fs::path ctrl = fs::path(project_dir) /
"ZCtrlPar.txt";
75 if (fs::is_regular_file(ctrl, ec))
76 files.push_back(ctrl);
77 fs::path input_dir = fs::path(project_dir) /
"Input";
78 if (fs::is_directory(input_dir, ec))
79 for (
auto&
e : fs::recursive_directory_iterator(input_dir, ec))
80 if (
e.is_regular_file(ec))
81 files.push_back(
e.path());
88 const fs::path base = fs::path(project_dir).lexically_normal();
89 auto rel_key = [&](
const fs::path& p) {
90 fs::path r = p.lexically_normal().lexically_relative(base);
91 return (r.empty() || *r.begin() ==
"..") ? p.filename().generic_string()
94 std::vector<std::pair<std::string, fs::path>> keyed;
95 keyed.reserve(files.size());
97 keyed.emplace_back(rel_key(p), p);
98 std::sort(keyed.begin(), keyed.end(),
99 [](
const auto& a,
const auto& b) { return a.first < b.first; });
101 for (
const auto& [key, p] : keyed) {
uint64_t compute_config_fingerprint(const std::string &project_dir, const std::string &deck_path)
Digest the configuration inputs of a project.
void fingerprint_feed_file(uint64_t &h, const std::filesystem::path &p)
Fold the contents of file p into h, read in 64 KiB blocks. A file that cannot be opened contributes n...
void fingerprint_feed(uint64_t &h, const char *data, size_t n)
Fold n bytes at data into the running 64-bit FNV-1a hash h (xor the byte, then multiply by the FNV pr...