diff --git a/CreateCargo.cpp b/CreateCargo.cpp index a505f5f..a4b5475 100644 --- a/CreateCargo.cpp +++ b/CreateCargo.cpp @@ -233,7 +233,7 @@ std::vector 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(&head.nameLen), sizeof(head.nameLen)); - cargo.write(head.nameFile.data(), head.nameLen); - + // Tablica pliku cargo.write(reinterpret_cast(&head.hashName), sizeof(head.hashName)); cargo.write(reinterpret_cast(&head.offset), sizeof(head.offset)); cargo.write(reinterpret_cast(&head.size), sizeof(head.size)); cargo.write(reinterpret_cast(&head.crc), sizeof(head.crc)); cargo.write(reinterpret_cast(&head.isZip), sizeof(head.isZip)); + + // Ścieżka do plików + cargo.write(reinterpret_cast(&head.nameLen), sizeof(head.nameLen)); + cargo.write(head.nameFile.data(), head.nameLen); } //Cofnij się na początek pliku diff --git a/CreateCargo.h b/CreateCargo.h index a705d18..7a94dfc 100644 --- a/CreateCargo.h +++ b/CreateCargo.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "DataStruct.h" #include "Txtpp.h" @@ -48,8 +49,6 @@ #define ALL_FILE ".*" // Wszystkie pliki - - class CreateCargo { public: CreateCargo(); @@ -121,7 +120,7 @@ private: std::string UpperString(std::string); // Wygenerój FNV-1a HASH - uint32_t fnv32(const std::string& data); + uint64_t fnv64(const std::string& data); // Rozdzielanie paternu od ścieżki void ExtPatternAndPathDetection(const std::vector&, std::vector&, std::vector&); diff --git a/DataStruct.h b/DataStruct.h index fe02eb7..650c6a8 100644 --- a/DataStruct.h +++ b/DataStruct.h @@ -59,7 +59,7 @@ struct FilesTable { uint8_t nameLen; std::string nameFile; - uint32_t hashName; + uint64_t hashName; uint64_t offset; uint32_t size; uint64_t crc; diff --git a/ExtractCargo.cpp b/ExtractCargo.cpp index bf5e028..fa170e4 100644 --- a/ExtractCargo.cpp +++ b/ExtractCargo.cpp @@ -136,17 +136,17 @@ void ExtractCargo::LoadFilesTable() for (uint32_t i = 0; i < filesLen; ++i) { FilesTable fhTmp; + cargoFile.read(reinterpret_cast(&fhTmp.hashName), sizeof(fhTmp.hashName)); + cargoFile.read(reinterpret_cast(&fhTmp.offset), sizeof(fhTmp.offset)); + cargoFile.read(reinterpret_cast(&fhTmp.size), sizeof(fhTmp.size)); + cargoFile.read(reinterpret_cast(&fhTmp.crc), sizeof(fhTmp.crc)); + cargoFile.read(reinterpret_cast(&fhTmp.isZip), sizeof(fhTmp.isZip)); cargoFile.read(reinterpret_cast(&fhTmp.nameLen), sizeof(fhTmp.nameLen)); std::vector nameBuffor(fhTmp.nameLen); cargoFile.read(nameBuffor.data(), fhTmp.nameLen); fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end()); - cargoFile.read(reinterpret_cast(&fhTmp.hashName), sizeof(fhTmp.hashName)); - cargoFile.read(reinterpret_cast(&fhTmp.offset), sizeof(fhTmp.offset)); - cargoFile.read(reinterpret_cast(&fhTmp.size), sizeof(fhTmp.size)); - cargoFile.read(reinterpret_cast(&fhTmp.crc), sizeof(fhTmp.crc)); - cargoFile.read(reinterpret_cast(&fhTmp.isZip), sizeof(fhTmp.isZip)); filesHeads.push_back(fhTmp); } diff --git a/ExtractCargo.h b/ExtractCargo.h index fbb28a6..0659a4a 100644 --- a/ExtractCargo.h +++ b/ExtractCargo.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "DataStruct.h" #include "xxhash.h" diff --git a/ViewCargo.cpp b/ViewCargo.cpp index d2b4349..2aa03c0 100644 --- a/ViewCargo.cpp +++ b/ViewCargo.cpp @@ -133,18 +133,18 @@ void ViewCargo::GetFileList(const std::string& path) for (uint32_t i = 0; i < filesLen; ++i) { FilesTable fhTmp; - cargo.read(reinterpret_cast(&fhTmp.nameLen), sizeof(fhTmp.nameLen)); - - std::vector nameBuffor(fhTmp.nameLen); - cargo.read(nameBuffor.data(), fhTmp.nameLen); - fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end()); - cargo.read(reinterpret_cast(&fhTmp.hashName), sizeof(fhTmp.hashName)); cargo.read(reinterpret_cast(&fhTmp.offset), sizeof(fhTmp.offset)); cargo.read(reinterpret_cast(&fhTmp.size), sizeof(fhTmp.size)); cargo.read(reinterpret_cast(&fhTmp.crc), sizeof(fhTmp.crc)); cargo.read(reinterpret_cast(&fhTmp.isZip), sizeof(fhTmp.isZip)); + cargo.read(reinterpret_cast(&fhTmp.nameLen), sizeof(fhTmp.nameLen)); + + std::vector nameBuffor(fhTmp.nameLen); + cargo.read(nameBuffor.data(), fhTmp.nameLen); + fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end()); + //Tworzenie wierszy tabeli CreateTableRow(fhTmp.nameFile, fhTmp.isZip, fhTmp.hashName); } @@ -155,7 +155,7 @@ void ViewCargo::GetFileList(const std::string& path) //----------------------------------------------------------------------------- // Generowanie wierszy do tabeli //----------------------------------------------------------------------------- -void ViewCargo::CreateTableRow(const std::string& file, const uint8_t& zip, const uint32_t& hash) +void ViewCargo::CreateTableRow(const std::string& file, const uint8_t& zip, const uint64_t& hash) { //Zamiania crc liczbowej na hex string std::stringstream ss; diff --git a/ViewCargo.h b/ViewCargo.h index 23e487e..bdfb7f8 100644 --- a/ViewCargo.h +++ b/ViewCargo.h @@ -48,7 +48,7 @@ private: bool CheckCargoFile(const std::string&); void GetFileList(const std::string&); void RenderList(); - void CreateTableRow(const std::string&, const uint8_t&, const uint32_t&); + void CreateTableRow(const std::string&, const uint8_t&, const uint64_t&); }; diff --git a/voidcmd.cpp b/voidcmd.cpp index e634293..bd326ff 100644 --- a/voidcmd.cpp +++ b/voidcmd.cpp @@ -86,10 +86,10 @@ int main(int argc, char* argv[]) { " 888 Y88b d88888 888 d8P \n" " 888 888 d88P888 888 d8P \n" " .d88b. 888 888 888 d88P d88P 888 888d88K \n" - "d8P Y8b `Y8bd8P' 8888888P' d88P 888 8888888b \n" + "d8P Y8b `Y8bd8P' 8888888P\" d88P 888 8888888b \n" "88888888 X88K 888 d88P 888 888 Y88b \n" - "Y8b. .d8''8b. 888 d8888888888 888 Y88b \n" - " 'Y8888 888 888 888 d88P 888 888 Y88b\n" + "Y8b. .d8\"\"8b. 888 d8888888888 888 Y88b \n" + " \"Y8888 888 888 888 d88P 888 888 Y88b\n" << std::endl; std::cout << "\n" << PROGRAM_VERSION << " Release " << PROGRAM_COMPILING << std::endl; std::cout << "Author: " << PROGRAM_AUTHOR << std::endl;