Mnieniono hash FNV-1a z 32b na 64b, String ścieżki do pliku przeniesiono na dół rekordu tablicy
This commit is contained in:
parent
4dbe684cd7
commit
942f94e1f0
8 changed files with 31 additions and 29 deletions
|
|
@ -233,7 +233,7 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
|||
FilesTable ft;
|
||||
ft.nameFile = path;
|
||||
ft.nameLen = path.length();
|
||||
ft.hashName = fnv32(path);
|
||||
ft.hashName = fnv64(path);
|
||||
ft.offset = offset;
|
||||
ft.size = zip.size();
|
||||
ft.isZip = method;
|
||||
|
|
@ -316,12 +316,12 @@ std::string CreateCargo::UpperString(std::string s) {
|
|||
//-----------------------------------------------------------------------------
|
||||
// Wygenerój FNV-1a HASH
|
||||
//-----------------------------------------------------------------------------
|
||||
uint32_t CreateCargo::fnv32(const std::string& data)
|
||||
uint64_t CreateCargo::fnv64(const std::string& data)
|
||||
{
|
||||
const uint32_t fnvOffset = 2166136261u;
|
||||
const uint32_t fnvPrime = 16777619u;
|
||||
const uint64_t fnvOffset = 14695981039346656037u;
|
||||
const uint64_t fnvPrime = 1099511628211u;
|
||||
|
||||
uint32_t hash = fnvOffset;
|
||||
uint64_t hash = fnvOffset;
|
||||
for (unsigned char c : data)
|
||||
{
|
||||
hash ^= c;
|
||||
|
|
@ -416,15 +416,16 @@ bool CreateCargo::WriteCargo()
|
|||
|
||||
for (const auto& head : filesHead)
|
||||
{
|
||||
// Œcie¿ka do plików
|
||||
cargo.write(reinterpret_cast<const char*>(&head.nameLen), sizeof(head.nameLen));
|
||||
cargo.write(head.nameFile.data(), head.nameLen);
|
||||
|
||||
// Tablica pliku
|
||||
cargo.write(reinterpret_cast<const char*>(&head.hashName), sizeof(head.hashName));
|
||||
cargo.write(reinterpret_cast<const char*>(&head.offset), sizeof(head.offset));
|
||||
cargo.write(reinterpret_cast<const char*>(&head.size), sizeof(head.size));
|
||||
cargo.write(reinterpret_cast<const char*>(&head.crc), sizeof(head.crc));
|
||||
cargo.write(reinterpret_cast<const char*>(&head.isZip), sizeof(head.isZip));
|
||||
|
||||
// Œcie¿ka do plików
|
||||
cargo.write(reinterpret_cast<const char*>(&head.nameLen), sizeof(head.nameLen));
|
||||
cargo.write(head.nameFile.data(), head.nameLen);
|
||||
}
|
||||
|
||||
//Cofnij siê na pocz¹tek pliku
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue