Zcalanie ręczne. Jak git nie chce po dobroci to będzie siłą
This commit is contained in:
parent
690e5278c5
commit
3bf98ba472
22 changed files with 790 additions and 457 deletions
|
|
@ -45,6 +45,8 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
|||
{
|
||||
cargoFileName = cFile;
|
||||
|
||||
std::cout << "START EXTRACT " << cFile << std::endl;
|
||||
|
||||
//Sprawdź czy plik istnieje
|
||||
if (!std::filesystem::exists(cargoFileName))
|
||||
{
|
||||
|
|
@ -59,6 +61,14 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Wczytaj klucz deszyfruj¹cy
|
||||
std::filesystem::path kdir = cargoFileName.stem();
|
||||
if (std::filesystem::exists(kdir.string() + ".key"))
|
||||
{
|
||||
std::cout << "Decryption key detected" << std::endl;
|
||||
eman.loadKey(kdir.string());
|
||||
}
|
||||
|
||||
//Otwieranie kontenera
|
||||
cargoFile.open(cargoFileName, std::ios::binary);
|
||||
|
||||
|
|
@ -79,7 +89,7 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
|||
bool ExtractCargo::CheckCargoFile()
|
||||
{
|
||||
std::vector<char> magic(signature.size());
|
||||
uint16_t cargoVer = 0;
|
||||
short cargoVer = 0;
|
||||
|
||||
if (!cargoFile.is_open())
|
||||
{
|
||||
|
|
@ -92,8 +102,6 @@ bool ExtractCargo::CheckCargoFile()
|
|||
cargoFile.read(reinterpret_cast<char*>(&filesLen), sizeof(filesLen));
|
||||
cargoFile.read(reinterpret_cast<char*>(&tablePosition), sizeof(tablePosition));
|
||||
|
||||
std::cout << std::string(magic.begin(), magic.end()) << std::endl;
|
||||
|
||||
if (std::string(magic.begin(), magic.end()) != signature)
|
||||
{
|
||||
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||
|
|
@ -126,13 +134,43 @@ bool ExtractCargo::HashValid(const std::vector<char>& data, const uint64_t& crc)
|
|||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Magiczna funkcja do dekompresji i deszyfracji danych
|
||||
//-----------------------------------------------------------------------------
|
||||
void ExtractCargo::computingBytes(const std::vector<char>& input, std::vector<char>& output, const int16_t& flag)
|
||||
{
|
||||
ChunkManager cm(eman);
|
||||
|
||||
switch (flag)
|
||||
{
|
||||
case 1:
|
||||
output = cm.dechunked(input, true, false);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
output = cm.dechunked(input, false, true);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
output = cm.dechunked(input, true, true);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
output = cm.dechunked(input, false, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
output = input;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Pobieranie nagłówków plików
|
||||
//-----------------------------------------------------------------------------
|
||||
void ExtractCargo::LoadFilesTable()
|
||||
{
|
||||
cargoFile.seekg(tablePosition);
|
||||
|
||||
for (uint32_t i = 0; i < filesLen; ++i)
|
||||
{
|
||||
FilesTable fhTmp;
|
||||
|
|
@ -146,7 +184,7 @@ void ExtractCargo::LoadFilesTable()
|
|||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.offset), sizeof(fhTmp.offset));
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.size), sizeof(fhTmp.size));
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.crc), sizeof(fhTmp.crc));
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.isZip), sizeof(fhTmp.isZip));
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.flag), sizeof(fhTmp.flag));
|
||||
|
||||
filesHeads.push_back(fhTmp);
|
||||
}
|
||||
|
|
@ -157,8 +195,6 @@ void ExtractCargo::LoadFilesTable()
|
|||
//-----------------------------------------------------------------------------
|
||||
void ExtractCargo::ExtractingFilesFromCargo()
|
||||
{
|
||||
CompressingManager cm;
|
||||
|
||||
for (const auto& fh : filesHeads)
|
||||
{
|
||||
std::filesystem::path dir = cargoFileName.stem() / fh.nameFile;
|
||||
|
|
@ -170,7 +206,8 @@ void ExtractCargo::ExtractingFilesFromCargo()
|
|||
|
||||
cargoFile.read(buffor.data(), fh.size);
|
||||
|
||||
std::vector<char> rawBuffor = fh.isZip ? cm.decompress(buffor) : buffor;
|
||||
std::vector<char> rawBuffor;
|
||||
computingBytes(buffor, rawBuffor, fh.flag);
|
||||
|
||||
if (!HashValid(rawBuffor, fh.crc))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue