blob: 17bd3a75f35f477ee5fddcf2bf8b6f40d84926ee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "hash.h"
#include <util/digest/city.h>
#include <util/generic/string.h>
#include <util/memory/blob.h>
#include <util/system/file.h>
#include <util/system/fstat.h>
void ReadFile(const char* fpath, TBlob& blob) {
TFile f(TString{fpath}, RdOnly | Seq);
const TFileStat fs(f);
auto size = fs.Size;
if (size < (64 << 10)) {
blob = TBlob::FromFileContent(f, 0, size);
} else {
blob = TBlob::FromFile(f);
}
}
ui64 FileCityHash128WithSeedHigh64(const char* fpath) {
TBlob blob;
ReadFile(fpath, blob);
const uint128 hash = CityHash128WithSeed((const char*)blob.Data(), blob.Size(), uint128(0, blob.Size()));
return Uint128High64(hash);
}
ui64 FileCityHash64(const char* fpath) {
TBlob blob;
ReadFile(fpath, blob);
return CityHash64(static_cast<const char*>(blob.Data()), blob.Size());
}
|