diff --git a/ChunkManager.cpp b/ChunkManager.cpp index aa7780c..6da9cc4 100644 --- a/ChunkManager.cpp +++ b/ChunkManager.cpp @@ -1,26 +1,6 @@ -/* - * This file is part of VoidArchiveTool. - * - * Copyright (C) 2025 Yanczi - * - * Void Archive Toolis free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ +#include "CompressingManager.h" -#include "ChunkManager.h" - -ChunkManager::ChunkManager(EncryptionManager& em) - :eman(em) +CompressingManager::CompressingManager() { } ChunkManager::~ChunkManager() @@ -56,17 +36,14 @@ std::vector ChunkManager::chunked(const std::vector& raw, const bool std::vector outChunk; - // Przetwórz chunki i przetwórz - if (compress) - { - // Zaszyfruj i skompresuj lub tylko skompresuj - outChunk = encrypt ? eman.encrypt(cman.compress(chunk)) : cman.compress(chunk); - } - else - { - // Zaszyfruj lub skopiuj - outChunk = encrypt ? eman.encrypt(chunk) : std::move(chunk); - } + // Buffor wyjściowy nadpisany skompresowanymi danymi + std::vector zipChunk(maxZipChunkSize); + + // Kompresja + int zipSize = LZ4_compress_default(chunk.data(), zipChunk.data(), chunkSize, maxZipChunkSize); + + // Zmiana rozmiaru do faktycznego rozmiaru po kompresji + zipChunk.resize(zipSize); uint32_t chs = static_cast(chunk.size()); uint32_t zch = static_cast(outChunk.size()); @@ -123,11 +100,19 @@ std::vector ChunkManager::dechunked(const std::vector& zip, const bo std::memcpy(inChunk.data(), zip.data() + offset, chunkZipSize); offset += chunkZipSize; - // Jeśli flaga encrypt jest aktywna najpierw zdeszyfruj blok - std::vector zipChunk = encrypt ? eman.decrypt(inChunk) : std::move(inChunk); - // Zdeklarój pusty chunk - std::vector chunk = compress ? cman.decompress(zipChunk, chunkSize) : std::move(zipChunk); + std::vector chunk(chunkSize); + + // Dekompresja chunka + int sizeData = LZ4_decompress_safe(zipChunk.data(), chunk.data(), static_cast(chunkZipSize), static_cast(chunkSize)); + + if (sizeData < 0) + { + throw std::runtime_error("LZ4 Decompressing Error"); + } + + // Dostosowanie rozmiaru vectora po skompresowaniu + chunk.resize(sizeData); // Scal chunki chunksString.insert(chunksString.end(), chunk.begin(), chunk.end()); diff --git a/ChunkManager.h b/ChunkManager.h index 006155d..c4e1f30 100644 --- a/ChunkManager.h +++ b/ChunkManager.h @@ -1,22 +1,3 @@ -/* - * This file is part of VoidArchiveTool. - * - * Copyright (C) 2025 Yanczi - * - * Void Archive Toolis free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - #pragma once #include diff --git a/README.md b/README.md index 704bf0a..20f79de 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ **Visual Studio 2022** +**CMAKE** +--soon-- **=========================================================================================** @@ -34,7 +36,13 @@   \*\*-c - Packing catalog width compressing all files\*\* - \*\*-p - Packing catalog width out compressing\*\* + \*\*-r - Raw files\*\* + + \*\*-c - Compressing\*\* + + \*\*-e - Encrypted\*\* + + \*\*-s - Compressing and encrypted\*\* \*\*-f - Packing catalog width unique config for individual files (look on under section)\*\* @@ -47,42 +55,6 @@ -**-f Parameters instruction** - - - -**Create regular txt file in same directory on catalog width same name.** - - - -**This is a config file width parameters** - - - -**{COMPRESS} - key for compress files list** - - - -**{COMPRESS}** - -**textures/texture.png** - -**\*.png** - - - -**{IGNORE} - key for ignoring files list** - - - -**{IGNORE}** - -**testfile.odt** - -**\*.odt** - - - **=========================================================================================** ### **Components:**