Zmiana metody kompresji na chunkowanie, zmiana nazwy z Void Archive na expak
This commit is contained in:
parent
f6150b0d17
commit
aef8daae9b
15 changed files with 320 additions and 93 deletions
|
|
@ -157,48 +157,38 @@ CargoHead CreateCargo::CreateCargoHead(const uint32_t& filesLen, const uint64_t&
|
|||
return ch;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Kompresowanie
|
||||
//-----------------------------------------------------------------------------
|
||||
std::vector<char> CreateCargo::Compressing(const std::vector<char>& raw)
|
||||
{
|
||||
int maxZipSize = LZ4_compressBound(raw.size());
|
||||
std::vector<char> zip(maxZipSize);
|
||||
int zipSize = LZ4_compress_default(raw.data(), zip.data(), raw.size(), maxZipSize);
|
||||
zip.resize(zipSize);
|
||||
|
||||
return zip;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sprawdza czy plik znajduje siê na liœcie
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CreateCargo::CheckFileOnTheList(const std::string& path, std::vector<char>& input, std::vector<char>& output)
|
||||
uint8_t CreateCargo::CheckFileOnTheList(const std::string& path, std::vector<char>& input, std::vector<char>& output)
|
||||
{
|
||||
//Flaga aktywna sprawdza czy plik jest na liœcie. Jeœli jest to zwraca surowedane
|
||||
//Przeciwnie kompresuje dane
|
||||
CompressingManager cm;
|
||||
|
||||
if (filteringFlag) {
|
||||
if (FilteringData(path))
|
||||
{
|
||||
output = Compressing(input);
|
||||
return true;
|
||||
output = cm.compress(input);
|
||||
return ZIP_FILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
output = std::move(input);
|
||||
return false;
|
||||
return RAW_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
//Flaga aktywna kompresuje dane
|
||||
if (compressingFlag)
|
||||
{
|
||||
output = Compressing(input);
|
||||
return true;
|
||||
|
||||
output = cm.compress(input);
|
||||
return ZIP_FILE;
|
||||
}
|
||||
|
||||
output = std::move(input);
|
||||
return false;
|
||||
return RAW_FILE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -238,15 +228,15 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
|||
|
||||
//Kompresjia
|
||||
std::vector<char> zip;
|
||||
bool isZip = CheckFileOnTheList(path, buffor, zip);
|
||||
uint8_t method = CheckFileOnTheList(path, buffor, zip);
|
||||
|
||||
FilesTable ft;
|
||||
ft.nameFile = path;
|
||||
ft.nameLen = path.length();
|
||||
ft.hashName = fnv32(path);
|
||||
ft.offset = offset;
|
||||
ft.size = zip.size();
|
||||
ft.rawSize = size;
|
||||
ft.isZip = isZip;
|
||||
ft.isZip = method;
|
||||
ft.crc = crc;
|
||||
|
||||
cargo.write(reinterpret_cast<const char*>(zip.data()), zip.size());
|
||||
|
|
@ -323,6 +313,24 @@ std::string CreateCargo::UpperString(std::string s) {
|
|||
return s;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Wygenerój FNV-1a HASH
|
||||
//-----------------------------------------------------------------------------
|
||||
uint32_t CreateCargo::fnv32(const std::string& data)
|
||||
{
|
||||
const uint32_t fnvOffset = 2166136261u;
|
||||
const uint32_t fnvPrime = 16777619u;
|
||||
|
||||
uint32_t hash = fnvOffset;
|
||||
for (unsigned char c : data)
|
||||
{
|
||||
hash ^= c;
|
||||
hash *= fnvPrime;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sprawdzanie czy plik znajduje siê na liœcie
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -412,9 +420,9 @@ bool CreateCargo::WriteCargo()
|
|||
cargo.write(reinterpret_cast<const char*>(&head.nameLen), sizeof(head.nameLen));
|
||||
cargo.write(head.nameFile.data(), head.nameLen);
|
||||
|
||||
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.rawSize), sizeof(head.rawSize));
|
||||
cargo.write(reinterpret_cast<const char*>(&head.crc), sizeof(head.crc));
|
||||
cargo.write(reinterpret_cast<const char*>(&head.isZip), sizeof(head.isZip));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue