MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / FileNameToHash

Function FileNameToHash

Sources/Shared/IO/PakFile.cpp:39–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37//###==##====#=====--==~--~=~- --- -- - - - -
38
39 static std::uint64_t FileNameToHash(StringView fileName)
40 {
41 SmallVector<char, 512> normalizedFileName(DefaultInit, fileName.size());
42 bool lastWasSlash = false;
43 std::size_t i = 0;
44
45 for (char c : fileName) {
46 // Normalize slashes
47 if (c == '\\') {
48 c = '/';
49 }
50
51 // Skip consecutive slashes
52 if (c == '/') {
53 if (lastWasSlash) continue;
54 lastWasSlash = true;
55 } else {
56 lastWasSlash = false;
57 }
58
59 // Uppercase to lowercase, copied from StringUtils::lowercaseInPlace()
60 c += (std::uint8_t(c - 'A') < 26) << 5;
61 normalizedFileName[i++] = c;
62 }
63
64 return xxHash3(normalizedFileName.data(), i);
65 }
66
67 static std::int64_t FindRelocatedFooter(std::unique_ptr<Death::IO::Stream>& s)
68 {

Callers 2

FindItemMethod · 0.85
AddFileMethod · 0.85

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected