Compare commits
43 commits
Encryption
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
109d10c3ca | ||
|
|
336e12d8c0 | ||
|
|
bfc6c1811d | ||
|
|
f9ea960cf0 | ||
|
|
8896624acc | ||
|
|
aea66dbfd9 | ||
|
|
6b0fbed103 | ||
|
|
e69bfd0e3d | ||
|
|
c2bdcfe2b9 | ||
|
|
608e382095 | ||
|
|
022bc0d069 | ||
|
|
91aaa279ec | ||
| a84a69cbd6 | |||
| b4f6d3a85a | |||
| f7d429e1d2 | |||
| cffba214e4 | |||
|
|
5310d4f27c | ||
|
|
c27949ff3f | ||
| 60455676a2 | |||
| bfb1bf5f61 | |||
| 712d767bff | |||
|
|
c733778e2e | ||
|
|
855f079bf7 | ||
|
|
58c3870c53 | ||
|
|
b9a4eaa87c | ||
|
|
9d4700c1b8 | ||
|
|
1a5f04988d | ||
|
|
d183360b70 | ||
|
|
b066f6ada5 | ||
|
|
45b2f823c6 | ||
|
|
1066a41359 | ||
|
|
56ac9715fe | ||
| 036568a109 | |||
|
|
fd42a5812a | ||
|
|
29b2460910 | ||
|
|
b3c317c914 | ||
|
|
00d4b00209 | ||
|
|
621b4b6eb7 | ||
|
|
293c1412ad | ||
|
|
8402ce1b65 | ||
|
|
31f08e52d0 | ||
| 66e776ee87 | |||
|
|
6335472904 |
30 changed files with 1008 additions and 993 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
|
@ -372,3 +372,13 @@ test.*
|
||||||
pest2.*
|
pest2.*
|
||||||
*.hh
|
*.hh
|
||||||
*.key
|
*.key
|
||||||
|
test3/
|
||||||
|
test4/
|
||||||
|
test5/
|
||||||
|
test6/
|
||||||
|
test7/
|
||||||
|
test8/
|
||||||
|
test9/
|
||||||
|
test10/
|
||||||
|
testx/
|
||||||
|
testv/
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
#include "CompressingManager.h"
|
|
||||||
|
|
||||||
CompressingManager::CompressingManager()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
CompressingManager::~CompressingManager()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Kompresja blokowa
|
|
||||||
//
|
|
||||||
// Dzielenie vectora na chunki dok³adnie po 128KB
|
|
||||||
// Kompresowanie chunków bez nag³ówka
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
std::vector<char> CompressingManager::compress(const std::vector<char>& raw)
|
|
||||||
{
|
|
||||||
//std::vector<BlockSize> blockSizes;
|
|
||||||
|
|
||||||
// Maksymalny rozmiar chunka
|
|
||||||
const size_t maxBlockSize = BLOCK_SIZE;
|
|
||||||
const size_t rawSize = raw.size();
|
|
||||||
|
|
||||||
uint16_t blockLen = 0;
|
|
||||||
uint32_t lastChunkRawSize;
|
|
||||||
std::vector<char> compressedBlocks;
|
|
||||||
for (size_t offset = 0; offset < rawSize; offset += maxBlockSize)
|
|
||||||
{
|
|
||||||
// Rozmiar chunka
|
|
||||||
const size_t chunkSize = std::min(maxBlockSize, rawSize - offset);
|
|
||||||
|
|
||||||
auto begin = raw.begin() + offset;
|
|
||||||
auto end = begin + chunkSize;
|
|
||||||
|
|
||||||
// Skopiuj fragment danych do chunka
|
|
||||||
std::vector<char> chunk(begin, end);
|
|
||||||
|
|
||||||
// Obliczanie rozmiaru skompresowanego bloku
|
|
||||||
int maxZipChunkSize = LZ4_compressBound(chunkSize);
|
|
||||||
|
|
||||||
// Buffor wyjœciowy nadpisany skompresowanymi danymi
|
|
||||||
std::vector<char> 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 = chunk.size();
|
|
||||||
uint32_t zch = zipChunk.size();
|
|
||||||
|
|
||||||
//addIntToVector<uint32_t>(compressedBlocks, chs);
|
|
||||||
lastChunkRawSize = chs;
|
|
||||||
addIntToVector<uint32_t>(compressedBlocks, zch);
|
|
||||||
compressedBlocks.insert(compressedBlocks.end(), zipChunk.begin(), zipChunk.end());
|
|
||||||
|
|
||||||
blockLen++;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<char> zip;
|
|
||||||
// Wstaw liczbê o iloœci bloków do vectora;
|
|
||||||
// Przekonpwertuj usigned int32 na ci¹g znkaów
|
|
||||||
//uint16_t blockLen = blockSizes .size();
|
|
||||||
addIntToVector<uint16_t>(zip, blockLen);
|
|
||||||
addIntToVector<uint32_t>(zip, maxBlockSize);
|
|
||||||
addIntToVector<uint32_t>(zip, lastChunkRawSize);
|
|
||||||
|
|
||||||
// Dodaj skompresowane dane
|
|
||||||
zip.insert(zip.end(), compressedBlocks.begin(), compressedBlocks.end());
|
|
||||||
|
|
||||||
return zip;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Dekompresja blokowa
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
std::vector<char> CompressingManager::decompress(const std::vector<char>& zip)
|
|
||||||
{
|
|
||||||
size_t offset = 0;
|
|
||||||
const uint16_t chunkLen = getIntFromVector<uint16_t>(zip, offset);
|
|
||||||
const uint32_t chunkBeforeSize = getIntFromVector<uint32_t>(zip, offset);
|
|
||||||
const uint32_t chunkLastSize = getIntFromVector<uint32_t>(zip, offset);
|
|
||||||
|
|
||||||
std::vector<char> chunksString;
|
|
||||||
|
|
||||||
// Dekompresja bloków
|
|
||||||
for (size_t i = 0; i < chunkLen; ++i)
|
|
||||||
{
|
|
||||||
// Pobierz rozmiar chunków przed i po skompresowaniem
|
|
||||||
uint32_t chunkSize = i < chunkLen - 1 ? chunkBeforeSize : chunkLastSize;
|
|
||||||
uint32_t chunkZipSize = getIntFromVector<uint32_t>(zip, offset);
|
|
||||||
|
|
||||||
// Pobierz blok chunka
|
|
||||||
std::vector<char> zipChunk(chunkZipSize);
|
|
||||||
std::memcpy(zipChunk.data(), zip.data() + offset, chunkZipSize);
|
|
||||||
offset += chunkZipSize;
|
|
||||||
|
|
||||||
// Zdeklarój pusty chunk
|
|
||||||
std::vector<char> chunk(chunkSize);
|
|
||||||
|
|
||||||
// Dekompresja chunka
|
|
||||||
int sizeData = LZ4_decompress_safe(zipChunk.data(), chunk.data(), static_cast<int>(chunkZipSize), static_cast<int>(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());
|
|
||||||
}
|
|
||||||
|
|
||||||
return chunksString;
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
#include <lz4.h>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#define BLOCK_SIZE 131072 // 128KB
|
|
||||||
|
|
||||||
struct BlockSize
|
|
||||||
{
|
|
||||||
uint32_t raw;
|
|
||||||
uint32_t zip;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CompressingManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CompressingManager();
|
|
||||||
~CompressingManager();
|
|
||||||
|
|
||||||
// Kompresja danych
|
|
||||||
std::vector<char> compress(const std::vector<char>&);
|
|
||||||
|
|
||||||
// Dekompresja
|
|
||||||
std::vector<char> decompress(const std::vector<char>&);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<BlockSize> blockSizes;
|
|
||||||
|
|
||||||
// Przekonwertuj zmienn¹ na ci¹g na vector
|
|
||||||
template <typename T>
|
|
||||||
void addIntToVector(std::vector<char>& vec, const T& val)
|
|
||||||
{
|
|
||||||
size_t tmpSize = vec.size();
|
|
||||||
vec.resize(tmpSize + sizeof(val));
|
|
||||||
std::memcpy(vec.data() + tmpSize, &val, sizeof(val));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pobierz zmienn¹ z vectora
|
|
||||||
template <typename T>
|
|
||||||
T getIntFromVector(const std::vector<char>& vec, size_t& offset)
|
|
||||||
{
|
|
||||||
T tmp{};
|
|
||||||
std::memcpy(&tmp, vec.data() + offset, sizeof(tmp));
|
|
||||||
offset += sizeof(tmp);
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
111
CompressionManager.cpp
Normal file
111
CompressionManager.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CompressionManager.h"
|
||||||
|
|
||||||
|
CompressionManager::CompressionManager()
|
||||||
|
:cctx(ZSTD_createCCtx())
|
||||||
|
,dctx(ZSTD_createDCtx())
|
||||||
|
{
|
||||||
|
// Ustawienia frameless
|
||||||
|
size_t rc = 0;
|
||||||
|
|
||||||
|
// Wy³¹cza ramkê i przestawia strumieñ na czyste bloki
|
||||||
|
rc |= ZSTD_CCtx_setParameter(cctx, ZSTD_c_format, ZSTD_f_zstd1_magicless);
|
||||||
|
|
||||||
|
// Wy³¹cza sumê kontroln¹ na poziomie ramki
|
||||||
|
rc |= ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, 0);
|
||||||
|
|
||||||
|
// Wy³¹cza zapisywanie „content size” w nag³ówku ramki
|
||||||
|
rc |= ZSTD_CCtx_setParameter(cctx, ZSTD_c_contentSizeFlag, 0);
|
||||||
|
|
||||||
|
// Wy³¹cza zapisywanie identyfikatora s³ownika
|
||||||
|
rc |= ZSTD_CCtx_setParameter(cctx, ZSTD_c_dictIDFlag, 0);
|
||||||
|
|
||||||
|
// Ustawia poziom kompresji
|
||||||
|
rc |= ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, zstd::compression_level);
|
||||||
|
|
||||||
|
if (ZSTD_isError(rc)) {
|
||||||
|
std::cerr << "ZSTD_CCtx_setParameter error" << std::endl;
|
||||||
|
ZSTD_freeCCtx(cctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*====Tutaj Dekompresja=============================================================*/
|
||||||
|
|
||||||
|
size_t r = 0;
|
||||||
|
|
||||||
|
// Przestawia dekompresjê na czyste bloki bez nag³ówka
|
||||||
|
r |= ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, ZSTD_f_zstd1_magicless);
|
||||||
|
if (ZSTD_isError(r))
|
||||||
|
{
|
||||||
|
std::cerr << "ZSTD_DCtx_setParameter error" << std::endl;
|
||||||
|
ZSTD_freeDCtx(dctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CompressionManager::~CompressionManager()
|
||||||
|
{
|
||||||
|
ZSTD_freeCCtx(cctx);
|
||||||
|
ZSTD_freeDCtx(dctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Kompresja ZSTD frameless
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::vector<char> CompressionManager::compress(const std::vector<char>& input)
|
||||||
|
{
|
||||||
|
// Obs³uga pustego chunku: zwracamy pusty wynik (0 bajtów).
|
||||||
|
if (input.empty()) return {};
|
||||||
|
|
||||||
|
const size_t srcSize = input.size();
|
||||||
|
|
||||||
|
// Szacowanie rozmiaru skompresowanego vectoru
|
||||||
|
const size_t maxDst = ZSTD_compressBound(srcSize);
|
||||||
|
|
||||||
|
std::vector<char> out(maxDst);
|
||||||
|
|
||||||
|
// Faktyczna kompresja
|
||||||
|
size_t written = ZSTD_compress2(cctx, out.data(), maxDst,
|
||||||
|
input.data(), srcSize);
|
||||||
|
|
||||||
|
if (ZSTD_isError(written)) {
|
||||||
|
std::cerr << "ZSTD_compress error: " << ZSTD_getErrorName(written) << std::endl;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
out.resize(written);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Dekompresja ZSTD
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::vector<char> CompressionManager::decompress(const std::vector<char>& input, const size_t& expected)
|
||||||
|
{
|
||||||
|
std::vector<char> output(expected);
|
||||||
|
|
||||||
|
size_t dsize = ZSTD_decompressDCtx(dctx, output.data(), expected, input.data(), input.size());
|
||||||
|
|
||||||
|
if (ZSTD_isError(dsize)) {
|
||||||
|
std::cerr << "ZSTD_decompressDCtx error: " << ZSTD_getErrorName(dsize) << "\n";
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
51
CompressionManager.h
Normal file
51
CompressionManager.h
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
#define ZSTD_STATIC_LINKING_ONLY
|
||||||
|
#include <zstd.h>
|
||||||
|
|
||||||
|
#if ZSTD_VERSION_NUMBER < 10400
|
||||||
|
#error "Wymagane zstd >= 1.4.0 dla ZSTD_c_format / ZSTD_f_zstd1_magicless"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace zstd
|
||||||
|
{
|
||||||
|
inline constexpr short compression_level = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CompressionManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CompressionManager();
|
||||||
|
~CompressionManager();
|
||||||
|
|
||||||
|
std::vector<char> compress(const std::vector<char>&);
|
||||||
|
std::vector<char> decompress(const std::vector<char>&, const size_t&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZSTD_CCtx* cctx;
|
||||||
|
ZSTD_DCtx* dctx;
|
||||||
|
};
|
||||||
|
|
||||||
404
CreateCargo.cpp
404
CreateCargo.cpp
|
|
@ -20,13 +20,15 @@
|
||||||
#include "CreateCargo.h"
|
#include "CreateCargo.h"
|
||||||
|
|
||||||
CreateCargo::CreateCargo()
|
CreateCargo::CreateCargo()
|
||||||
: signature(SIGNATURE)
|
: signature(fl::sigpak)
|
||||||
, extension(EXTENSION)
|
, extension(fl::extpak)
|
||||||
, version(VERSION)
|
|
||||||
, methodFlags(0)
|
, methodFlags(0)
|
||||||
|
, xxhState(XXH64_createState())
|
||||||
, offset(0)
|
, offset(0)
|
||||||
|
, hppKey(false)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
|
XXH64_reset(xxhState, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateCargo::~CreateCargo() {
|
CreateCargo::~CreateCargo() {
|
||||||
|
|
@ -37,7 +39,7 @@ CreateCargo::~CreateCargo() {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Punk wejścia do tworzenia archivum
|
// Punk wejścia do tworzenia archivum
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CreateCargo::Create(const std::string& path, int8_t flag)
|
bool CreateCargo::Create(const std::string& path, const uint8_t& flag)
|
||||||
{
|
{
|
||||||
cargoFile = path + "." + extension;
|
cargoFile = path + "." + extension;
|
||||||
catalogPath = path;
|
catalogPath = path;
|
||||||
|
|
@ -56,14 +58,6 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Pobieranie listy plików do spakowania
|
|
||||||
std::cout << "Creating a file list..." << std::endl;
|
|
||||||
if (!GetFileList(path))
|
|
||||||
{
|
|
||||||
std::cerr << "Error: The specified directory contains no files!" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pobieranie listy plików wyjątków
|
// Pobieranie listy plików wyjątków
|
||||||
if (flag == -1)
|
if (flag == -1)
|
||||||
{
|
{
|
||||||
|
|
@ -76,6 +70,14 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
|
||||||
GetFilters(filterFile);
|
GetFilters(filterFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Pobieranie listy plików do spakowania
|
||||||
|
std::cout << "Creating a file list..." << std::endl;
|
||||||
|
if (!GetFileList(path))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The specified directory contains no files!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Utworzenie kontenera
|
// Utworzenie kontenera
|
||||||
cargo.open(cargoFile, std::ios::binary);
|
cargo.open(cargoFile, std::ios::binary);
|
||||||
|
|
||||||
|
|
@ -86,6 +88,12 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zapisywanie klucza szyfruj¹cego
|
||||||
|
if (flag == flag::enc || flag == flag::ezd || encList.size() > 0)
|
||||||
|
{
|
||||||
|
eman.saveKey(catalogPath, hppKey);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,14 +111,43 @@ bool CreateCargo::GetFileList(const std::string& path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CheckIgnorePath(tmpPath))
|
std::string fileRef = RemoveStartPath(PathToUnixLike(tmpPath));
|
||||||
|
|
||||||
|
if (fileRef.length() > 255)
|
||||||
{
|
{
|
||||||
filesList.push_back(PathToUnixLike(tmpPath));
|
std::cerr << "The file path is too long. It exceeds 255 characters." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PathConf pc;
|
||||||
|
if (methodFlags != 0xAB)
|
||||||
|
{
|
||||||
|
pc.path = PathToUnixLike(tmpPath);
|
||||||
|
pc.parameter = methodFlags;
|
||||||
|
filesPaths.push_back(pc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!FindOnTheList(ignoreList, fileRef) || !CheckFileExtension(fileRef, ignoreList))
|
||||||
|
{
|
||||||
|
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
|
||||||
|
{
|
||||||
|
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? flag::ezd : flag::zip;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? flag::enc : flag::raw;
|
||||||
|
}
|
||||||
|
pc.path = PathToUnixLike(tmpPath);
|
||||||
|
std::cout << pc.path << " - " << pc.parameter << std::endl;
|
||||||
|
filesPaths.push_back(pc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filesList.size() > 0 ? true : false;
|
return filesPaths.size() > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -147,49 +184,13 @@ CargoHead CreateCargo::CreateCargoHead(const uint32_t& filesLen, const uint64_t&
|
||||||
{
|
{
|
||||||
CargoHead ch;
|
CargoHead ch;
|
||||||
|
|
||||||
ch.signature = signature;
|
ch.signature = fl::sigpak;
|
||||||
ch.version = version;
|
|
||||||
ch.files = filesLen;
|
|
||||||
ch.table = table;
|
ch.table = table;
|
||||||
|
ch.files = filesLen;
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Sprawdza czy plik znajduje siê na liœcie
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
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;
|
|
||||||
|
|
||||||
// Kompresja
|
|
||||||
if (methodFlags == 1)
|
|
||||||
{
|
|
||||||
output = cm.compress(input);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Szyfrowanie
|
|
||||||
if (methodFlags == 2)
|
|
||||||
{
|
|
||||||
output = crypt.encrypt(input);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kompresja i szyfrowanie
|
|
||||||
if (methodFlags == 3)
|
|
||||||
{
|
|
||||||
output = crypt.encrypt(cm.compress(input));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zwraca surowe dane
|
|
||||||
output = std::move(input);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Przygotowanie nagłówków i plików
|
// Przygotowanie nagłówków i plików
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -197,52 +198,123 @@ std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
||||||
{
|
{
|
||||||
//Utwórz header TMP. Zabezpiecza Pierwsze bajty na właściwy nagłówek
|
//Utwórz header TMP. Zabezpiecza Pierwsze bajty na właściwy nagłówek
|
||||||
CargoHead cargoHead = CreateCargoHead(0, 0);
|
CargoHead cargoHead = CreateCargoHead(0, 0);
|
||||||
offset += cargoHead.signature.length() + sizeof(cargoHead.version) + sizeof(cargoHead.files) + sizeof(cargoHead.table);
|
offset += cargoHead.signature.length() + sizeof(cargoHead.files) + sizeof(cargoHead.table);
|
||||||
|
|
||||||
//Zapisanie TMP nag³owka do pliku
|
//Zapisanie tymczasowego nag³owka jako rezerwacja miejsca
|
||||||
cargo.write(cargoHead.signature.data(), cargoHead.signature.length());
|
cargo.write(cargoHead.signature.data(), cargoHead.signature.length());
|
||||||
cargo.write(reinterpret_cast<const char*>(&cargoHead.version), sizeof(cargoHead.version));
|
|
||||||
cargo.write(reinterpret_cast<const char*>(&cargoHead.files), sizeof(cargoHead.files));
|
|
||||||
cargo.write(reinterpret_cast<const char*>(&cargoHead.table), sizeof(cargoHead.table));
|
cargo.write(reinterpret_cast<const char*>(&cargoHead.table), sizeof(cargoHead.table));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&cargoHead.files), sizeof(cargoHead.files));
|
||||||
|
|
||||||
std::vector<FilesTable> filesTable;
|
std::vector<FilesTable> filesTable;
|
||||||
|
|
||||||
//Tworzenie nag³ówków plików
|
//Tworzenie nag³ówków plików jednoczeœnie zapisywanie plików
|
||||||
for (const auto& file : filesList)
|
for (const auto& file : filesPaths)
|
||||||
{
|
{
|
||||||
std::string path = PathToUnixLike(RemoveStartPath(file));
|
std::string path = PathToUnixLike(RemoveStartPath(file.path));
|
||||||
std::ifstream f(file, std::ios::binary | std::ios::ate);
|
std::ifstream f(file.path, std::ios::binary | std::ios::ate);
|
||||||
|
|
||||||
|
std::cout << path << std::endl;
|
||||||
|
|
||||||
//Obliczanie rozmiaru pliku
|
//Obliczanie rozmiaru pliku
|
||||||
size_t size = f.tellg();
|
size_t size = f.tellg();
|
||||||
f.seekg(0, std::ios::beg);
|
f.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
//Wczytanie pliku do pamiêci
|
if (size > ds::maxFileSize)
|
||||||
std::vector<char> buffor(size);
|
{
|
||||||
f.read(buffor.data(), size);
|
std::cerr << path << " is too large. It exceeds " << ds::maxFileSize / 1024 / 1024 / 1024 << "GB!" << std::endl;
|
||||||
f.close();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XXH64_reset(xxhState, 0);
|
||||||
|
|
||||||
//Tworzenie hashu CRC
|
//Wczytanie pliku do pamiêci
|
||||||
const uint64_t crc = XXH64(buffor.data(), buffor.size(), VERSION);
|
std::vector<char> buffer(ds::chunk_stream);
|
||||||
|
|
||||||
//Kompresjia
|
uint64_t sizeFile = 0;
|
||||||
std::vector<char> zip;
|
|
||||||
uint8_t method = CheckFileOnTheList(path, buffor, zip);
|
|
||||||
|
|
||||||
FilesTable ft;
|
const uint32_t chunkBlockSize = ds::block_size;
|
||||||
ft.nameFile = path;
|
const uint32_t quantity = (size + chunkBlockSize) / chunkBlockSize;
|
||||||
ft.nameLen = path.length();
|
const uint32_t lastChunkSize = size - (chunkBlockSize * (quantity - 1));
|
||||||
ft.hashName = fnv64(path);
|
|
||||||
ft.offset = offset;
|
|
||||||
ft.size = zip.size();
|
|
||||||
ft.isZip = method;
|
|
||||||
ft.crc = crc;
|
|
||||||
|
|
||||||
cargo.write(reinterpret_cast<const char*>(zip.data()), zip.size());
|
// Jeœli jest ustawiona flaga inna ni¿ RAW
|
||||||
|
// Dodaj do kontenera konfiguracjê chunków
|
||||||
|
if (file.parameter != flag::raw)
|
||||||
|
{
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&quantity), sizeof(quantity));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&chunkBlockSize), sizeof(chunkBlockSize));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&lastChunkSize), sizeof(lastChunkSize));
|
||||||
|
sizeFile = sizeof(quantity) + sizeof(chunkBlockSize) + sizeof(lastChunkSize);
|
||||||
|
}
|
||||||
|
|
||||||
filesTable.push_back(ft);
|
// Strumieniowanie danych
|
||||||
offset += zip.size();
|
while (f.read(buffer.data(), ds::chunk_stream) || f.gcount() > 0)
|
||||||
|
{
|
||||||
|
const int bufferSize = f.gcount();
|
||||||
|
buffer.resize(bufferSize);
|
||||||
|
|
||||||
|
// Aktualizacja XXH64
|
||||||
|
XXH64_update(xxhState, buffer.data(), buffer.size());
|
||||||
|
|
||||||
|
if (file.parameter == flag::raw)
|
||||||
|
{
|
||||||
|
// Zapisywanie strumienia do kontenera
|
||||||
|
cargo.write(reinterpret_cast<const char*>(buffer.data()), buffer.size());
|
||||||
|
sizeFile += bufferSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint32_t ofs = 0; ofs < bufferSize; ofs += chunkBlockSize)
|
||||||
|
{
|
||||||
|
// Rozmiar chunka
|
||||||
|
const uint32_t chunkSize = std::min(chunkBlockSize, bufferSize - ofs);
|
||||||
|
|
||||||
|
auto begin = buffer.begin() + ofs;
|
||||||
|
auto end = begin + chunkSize;
|
||||||
|
|
||||||
|
// Skopiuj fragment danych do chunka
|
||||||
|
std::vector<char> chunk(begin, end);
|
||||||
|
|
||||||
|
std::vector<char> outChunk;
|
||||||
|
|
||||||
|
// Przetwórz chunki i przetwórz
|
||||||
|
if ((file.parameter & flag::zip) == flag::zip)
|
||||||
|
{
|
||||||
|
// Zaszyfruj i skompresuj lub tylko skompresuj
|
||||||
|
outChunk = (file.parameter & flag::enc) == flag::enc ?
|
||||||
|
eman.encrypt(cman.compress(chunk)) : cman.compress(chunk);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Zaszyfruj lub skopiuj
|
||||||
|
outChunk = eman.encrypt(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t outSize = outChunk.size();
|
||||||
|
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&outSize), sizeof(outSize));
|
||||||
|
sizeFile += sizeof(outSize);
|
||||||
|
|
||||||
|
cargo.write(reinterpret_cast<const char*>(outChunk.data()), outChunk.size());
|
||||||
|
sizeFile += outSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
FilesTable ft;
|
||||||
|
ft.nameFile = path;
|
||||||
|
ft.nameLen = path.length();
|
||||||
|
ft.offset = offset;
|
||||||
|
ft.size = sizeFile;
|
||||||
|
ft.flag = file.parameter;
|
||||||
|
ft.crc = XXH64_digest(xxhState);
|
||||||
|
|
||||||
|
filesTable.push_back(ft);
|
||||||
|
offset += sizeFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filesTable;
|
return filesTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,42 +331,26 @@ void CreateCargo::GetFilters(const std::string& filterFile)
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// Lista plików do skompresowania
|
// Lista plików do skompresowania
|
||||||
std::vector<std::string> zip = jslist[KEY_ZIP].get<std::vector<std::string>>();
|
if (jslist.contains(key::zip))
|
||||||
|
{
|
||||||
|
zipList = jslist[key::zip].get<std::vector<std::string>>();
|
||||||
|
}
|
||||||
|
|
||||||
// Lista plików do zaszyfrowania
|
// Lista plików do zaszyfrowania
|
||||||
std::vector<std::string> enc = jslist[KEY_ENCRYPT].get<std::vector<std::string>>();
|
if (jslist.contains(key::enc))
|
||||||
|
{
|
||||||
|
encList = jslist[key::enc].get<std::vector<std::string>>();
|
||||||
|
}
|
||||||
|
|
||||||
// Lista plików do pominięcia
|
// Lista plików do pominięcia
|
||||||
std::vector<std::string> ignore = jslist[KEY_IGNORE].get<std::vector<std::string>>();
|
if (jslist.contains(key::ignore))
|
||||||
|
|
||||||
PrepareList(zip, enc, ignore);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Przygotuj listê plików do spakowania
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CreateCargo::PrepareList(const std::vector<std::string>& zip, const std::vector<std::string>& enc, const std::vector<std::string>& ignore)
|
|
||||||
{
|
|
||||||
PathConf pc;
|
|
||||||
|
|
||||||
for (const auto& item : filesList)
|
|
||||||
{
|
{
|
||||||
if (!FindOnTheList(ignore, item))
|
ignoreList = jslist[key::ignore].get<std::vector<std::string>>();
|
||||||
{
|
|
||||||
if (FindOnTheList(zip, item))
|
|
||||||
{
|
|
||||||
pc.parameter = FindOnTheList(enc, item) ? 3 : 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pc.parameter = FindOnTheList(enc, item) ? 2 : 0;
|
|
||||||
}
|
|
||||||
pc.path = item;
|
|
||||||
filesPaths.push_back(pc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// Flaga tworzenia klucza jako plik nag³ówka c++
|
||||||
|
hppKey = jslist.value(key::hpp, false);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Znajdź wskazany element na liście
|
// Znajdź wskazany element na liście
|
||||||
|
|
@ -305,33 +361,23 @@ bool CreateCargo::FindOnTheList(const std::vector<std::string>& list, const std:
|
||||||
return it == list.end() ? false : true;
|
return it == list.end() ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Rozdzielanie paternu od œcie¿ki
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CreateCargo::ExtPatternAndPathDetection(const std::vector<std::string>& data, std::vector<std::string>& pattern, std::vector<std::string>& path)
|
|
||||||
{
|
|
||||||
for (const auto& d : data)
|
|
||||||
{
|
|
||||||
if (d.front() == '*')
|
|
||||||
{
|
|
||||||
std::string tmpPattern = d;
|
|
||||||
tmpPattern.erase(tmpPattern.begin());
|
|
||||||
pattern.push_back(UpperString(tmpPattern));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
path.push_back(d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Sprawdzanie rozszeżeń plików
|
// Sprawdzanie rozszeżeń plików
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CreateCargo::CheckFileExtension(const std::filesystem::path& p, const std::vector<std::string>& patterns) {
|
bool CreateCargo::CheckFileExtension(const std::string& p, const std::vector<std::string>& patterns) {
|
||||||
std::string ext = UpperString(p.extension().string());
|
std::filesystem::path _p = p;
|
||||||
|
std::string ext = "*" + UpperString(_p.extension().string());
|
||||||
|
|
||||||
return FindOnTheList(patterns, ext);
|
for (const auto& e : patterns)
|
||||||
|
{
|
||||||
|
std::string element = UpperString(e);
|
||||||
|
if (element == ext)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -343,87 +389,6 @@ std::string CreateCargo::UpperString(std::string s) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Wygenerój FNV-1a HASH
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
uint64_t CreateCargo::fnv64(const std::string& data)
|
|
||||||
{
|
|
||||||
const uint64_t fnvOffset = 14695981039346656037u;
|
|
||||||
const uint64_t fnvPrime = 1099511628211u;
|
|
||||||
|
|
||||||
uint64_t hash = fnvOffset;
|
|
||||||
for (unsigned char c : data)
|
|
||||||
{
|
|
||||||
hash ^= c;
|
|
||||||
hash *= fnvPrime;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Sprawdzanie czy plik znajduje siê na liœcie
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool CreateCargo::FilteringData(const std::string& path)
|
|
||||||
{
|
|
||||||
std::vector<std::string> cmPatterns;
|
|
||||||
std::vector<std::string> cmPaths;
|
|
||||||
|
|
||||||
// Rozdziel œcie¿ki i patterny na osobne listy
|
|
||||||
ExtPatternAndPathDetection(zipList, cmPatterns, cmPaths);
|
|
||||||
|
|
||||||
if (FindOnTheList(cmPatterns, ALL_FILE))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sprawd¿ czy istnieje plik o danym rozsze¿eniu
|
|
||||||
if (CheckFileExtension(path, cmPatterns))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SprawdŸ czy instnieje dany plik w danej lokalizacji
|
|
||||||
if (FindOnTheList(cmPaths, path))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Kasowanie z listy plików ignorow
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool CreateCargo::CheckIgnorePath(const std::string& path)
|
|
||||||
{
|
|
||||||
std::vector<std::string> igPatterns;
|
|
||||||
std::vector<std::string> igPaths;
|
|
||||||
|
|
||||||
ExtPatternAndPathDetection(ignoreList, igPatterns, igPaths);
|
|
||||||
|
|
||||||
// Sprawd¿ czy istnieje plik o danym rozsze¿eniu
|
|
||||||
if (CheckFileExtension(path, igPatterns))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obrubka œcierzki
|
|
||||||
// Usuwanie katalogu root
|
|
||||||
std::string cleanPath = RemoveStartPath(path);
|
|
||||||
|
|
||||||
// Przekszta³cenie œcierzki na format unixowy
|
|
||||||
std::string unixPath = PathToUnixLike(cleanPath);
|
|
||||||
|
|
||||||
// SprawdŸ czy instnieje dany plik w danej lokalizacji
|
|
||||||
if (FindOnTheList(igPaths, unixPath))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Trworzenie archiwum
|
// Trworzenie archiwum
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -431,7 +396,7 @@ bool CreateCargo::WriteCargo()
|
||||||
{
|
{
|
||||||
std::cout << "Packing files..." << std::endl;
|
std::cout << "Packing files..." << std::endl;
|
||||||
|
|
||||||
uint32_t filesLen = filesList.size();
|
uint32_t filesLen = filesPaths.size();
|
||||||
|
|
||||||
//Przygotowanie nagłówków plików i przetworzenie danych
|
//Przygotowanie nagłówków plików i przetworzenie danych
|
||||||
std::vector<FilesTable> filesHead = ComputingHeadFiles();
|
std::vector<FilesTable> filesHead = ComputingHeadFiles();
|
||||||
|
|
@ -450,11 +415,10 @@ bool CreateCargo::WriteCargo()
|
||||||
cargo.write(reinterpret_cast<const char*>(&head.nameLen), sizeof(head.nameLen));
|
cargo.write(reinterpret_cast<const char*>(&head.nameLen), sizeof(head.nameLen));
|
||||||
cargo.write(head.nameFile.data(), 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.offset), sizeof(head.offset));
|
||||||
cargo.write(reinterpret_cast<const char*>(&head.size), sizeof(head.size));
|
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.crc), sizeof(head.crc));
|
||||||
cargo.write(reinterpret_cast<const char*>(&head.isZip), sizeof(head.isZip));
|
cargo.write(reinterpret_cast<const char*>(&head.flag), sizeof(head.flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cofnij się na początek pliku
|
//Cofnij się na początek pliku
|
||||||
|
|
@ -465,15 +429,11 @@ bool CreateCargo::WriteCargo()
|
||||||
|
|
||||||
//Nadpisz tymczasowy nagłówek
|
//Nadpisz tymczasowy nagłówek
|
||||||
cargo.write(cargoHead.signature.data(), cargoHead.signature.length());
|
cargo.write(cargoHead.signature.data(), cargoHead.signature.length());
|
||||||
cargo.write(reinterpret_cast<const char*>(&cargoHead.version), sizeof(cargoHead.version));
|
|
||||||
cargo.write(reinterpret_cast<const char*>(&cargoHead.files), sizeof(cargoHead.files));
|
|
||||||
cargo.write(reinterpret_cast<const char*>(&cargoHead.table), sizeof(cargoHead.table));
|
cargo.write(reinterpret_cast<const char*>(&cargoHead.table), sizeof(cargoHead.table));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&cargoHead.files), sizeof(cargoHead.files));
|
||||||
|
|
||||||
cargo.close();
|
cargo.close();
|
||||||
|
|
||||||
// Zapisywanie klucza szyfruj¹cego
|
|
||||||
//crypt.saveKey(catalogPath);
|
|
||||||
|
|
||||||
std::cout << "The container was successfully created! " << cargoFile << std::endl;
|
std::cout << "The container was successfully created! " << cargoFile << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <lz4.h>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -34,26 +33,32 @@
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include "DataStruct.h"
|
#include "DataStruct.h"
|
||||||
#include "Txtpp.h"
|
|
||||||
#include "CompressingManager.h"
|
|
||||||
#include "EncryptionManager.h"
|
#include "EncryptionManager.h"
|
||||||
|
#include "CompressionManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define KEY_ZIP "compress" // Pliki do skompresowania
|
||||||
|
#define KEY_RAW "raw" // Pliki które maj¹ pozostaæ w oryginalnej formie
|
||||||
|
#define KEY_IGNORE "ignore" // Pliki pominiête przy pakowaniu
|
||||||
|
#define KEY_ENCRYPT "encrypt" // Plili które maj¹ byæ zaszyfrowane
|
||||||
|
|
||||||
|
#define ALL_FILE ".*" // Wszystkie pliki
|
||||||
|
|
||||||
#define COMPRESSION_LEVEL 12 // Poziom kompresji plików (3 < 12)
|
namespace key
|
||||||
|
{
|
||||||
|
inline constexpr std::string_view zip = "compress";
|
||||||
|
inline constexpr std::string_view raw = "raw";
|
||||||
|
inline constexpr std::string_view enc = "encrypt";
|
||||||
|
inline constexpr std::string_view ignore = "ignore";
|
||||||
|
inline constexpr std::string_view all = ".*";
|
||||||
|
|
||||||
#define KEY_ZIP "COMPRESS" // Pliki do skompresowania
|
inline constexpr std::string_view hpp = "keyhpp";
|
||||||
#define KEY_RAW "RAW" // Pliki które maj¹ pozostaæ w oryginalnej formie
|
}
|
||||||
#define KEY_IGNORE "IGNORE" // Pliki pominiête przy pakowaniu
|
|
||||||
#define KEY_ENCRYPT "ENCRYPT" // Plili które maj¹ byæ zaszyfrowane
|
|
||||||
|
|
||||||
#define ALL_FILE ".*" // Wszystkie pliki
|
|
||||||
|
|
||||||
struct PathConf
|
struct PathConf
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
int8_t parameter;
|
uint8_t parameter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CreateCargo {
|
class CreateCargo {
|
||||||
|
|
@ -62,14 +67,15 @@ public:
|
||||||
virtual ~CreateCargo();
|
virtual ~CreateCargo();
|
||||||
|
|
||||||
// Punk wejœcia do tworzenia archivum
|
// Punk wejœcia do tworzenia archivum
|
||||||
bool Create(const std::string&, int8_t);
|
bool Create(const std::string&, const uint8_t&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string signature;
|
const std::string signature;
|
||||||
const std::string extension;
|
const std::string extension;
|
||||||
const uint8_t version;
|
|
||||||
|
|
||||||
int8_t methodFlags;
|
uint8_t methodFlags;
|
||||||
|
|
||||||
|
XXH64_state_t* xxhState;
|
||||||
|
|
||||||
|
|
||||||
std::string catalogPath;
|
std::string catalogPath;
|
||||||
|
|
@ -78,11 +84,14 @@ private:
|
||||||
|
|
||||||
std::vector<std::string> filesList;
|
std::vector<std::string> filesList;
|
||||||
|
|
||||||
EncryptionManager crypt;
|
EncryptionManager eman;
|
||||||
|
CompressionManager cman;
|
||||||
|
bool hppKey;
|
||||||
|
|
||||||
// listy wyj¹tków
|
// listy wyj¹tków
|
||||||
std::vector<std::string> ignoreList;
|
std::vector<std::string> ignoreList;
|
||||||
std::vector<std::string> zipList;
|
std::vector<std::string> zipList;
|
||||||
|
std::vector<std::string> encList;
|
||||||
|
|
||||||
// G³ówna lista plików z parametrami
|
// G³ówna lista plików z parametrami
|
||||||
std::vector<PathConf> filesPaths;
|
std::vector<PathConf> filesPaths;
|
||||||
|
|
@ -92,7 +101,6 @@ private:
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Tworzenie listy plików do spakowania
|
// Tworzenie listy plików do spakowania
|
||||||
bool GetFileList(const std::string&);
|
bool GetFileList(const std::string&);
|
||||||
|
|
||||||
|
|
@ -111,34 +119,16 @@ private:
|
||||||
// Przygotowanie nag³ówków i plików
|
// Przygotowanie nag³ówków i plików
|
||||||
std::vector<FilesTable> ComputingHeadFiles();
|
std::vector<FilesTable> ComputingHeadFiles();
|
||||||
|
|
||||||
// Sprawdzanie czy plik znajduje siê na liœcie
|
|
||||||
bool FilteringData(const std::string&);
|
|
||||||
|
|
||||||
// Wczytanie filtrów wyj¹tków
|
// Wczytanie filtrów wyj¹tków
|
||||||
void GetFilters(const std::string&);
|
void GetFilters(const std::string&);
|
||||||
|
|
||||||
// Sprawdza czy plik znajduje siê na liœcie
|
|
||||||
uint8_t CheckFileOnTheList(const std::string&, std::vector<char>&, std::vector<char>&);
|
|
||||||
|
|
||||||
// Kasowanie z listy plików ignorow
|
|
||||||
bool CheckIgnorePath(const std::string&);
|
|
||||||
|
|
||||||
// Sprawdzanie rozsze¿eñ plików
|
// Sprawdzanie rozsze¿eñ plików
|
||||||
bool CheckFileExtension(const std::filesystem::path&, const std::vector<std::string>&);
|
bool CheckFileExtension(const std::string&, const std::vector<std::string>&);
|
||||||
|
|
||||||
// Zamieñ ca³y ci¹g na du¿e litery
|
// Zamieñ ca³y ci¹g na du¿e litery
|
||||||
std::string UpperString(std::string);
|
std::string UpperString(std::string);
|
||||||
|
|
||||||
// Wygenerój FNV-1a HASH
|
|
||||||
uint64_t fnv64(const std::string& data);
|
|
||||||
|
|
||||||
// Rozdzielanie paternu od œcie¿ki
|
|
||||||
void ExtPatternAndPathDetection(const std::vector<std::string>&, std::vector<std::string>&, std::vector<std::string>&);
|
|
||||||
|
|
||||||
// ZnajdŸ wskazany element na liœcie
|
// ZnajdŸ wskazany element na liœcie
|
||||||
bool FindOnTheList(const std::vector<std::string>&, const std::string&);
|
bool FindOnTheList(const std::vector<std::string>&, const std::string&);
|
||||||
|
|
||||||
// Przygotuj listê plików do spakowania
|
|
||||||
void PrepareList(const std::vector<std::string>&, const std::vector<std::string>&, const std::vector<std::string>&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
72
DataStruct.h
72
DataStruct.h
|
|
@ -22,55 +22,61 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define EXTENSION "pak"
|
namespace ui
|
||||||
#define SIGNATURE "XPAK"
|
|
||||||
|
|
||||||
#define SIGNATURE_KEY_FILE 1497713496 // XKEY
|
|
||||||
|
|
||||||
#define VERSION 100
|
|
||||||
|
|
||||||
enum StoreMethod
|
|
||||||
{
|
{
|
||||||
FILTERING = -1,
|
inline constexpr std::string_view title = "exPak";
|
||||||
RAW = 0,
|
inline constexpr std::string_view ver = "0.5";
|
||||||
COMPRESS = 1,
|
}
|
||||||
ENCRYPT = 2,
|
|
||||||
COMPRESSxENCRYPT = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Pliki
|
||||||
|
namespace fl
|
||||||
|
{
|
||||||
|
inline constexpr std::string_view sigpak = "XPAK";
|
||||||
|
inline constexpr std::string_view sigkey = "XKEY";
|
||||||
|
|
||||||
//Prgoram title
|
inline constexpr std::string_view extpak = "pak";
|
||||||
#define PROGRAM_TITLE "eXtendet PAK"
|
inline constexpr std::string_view extkey = "key";
|
||||||
#define PROGRAM_VERSION "v1.1"
|
}
|
||||||
#define PROGRAM_AUTHOR "Yanczi"
|
|
||||||
#define PROGRAM_COMPILING "24 October 2025"
|
|
||||||
#define PROGRAM_LICENSE "GNU LGPL v3"
|
|
||||||
|
|
||||||
//Limity
|
// Size
|
||||||
#define MAX_FILE_SIZE 2147483648 // 2GB
|
namespace ds
|
||||||
#define MAX_PAK_SIZE 8796093022208 // 8TB
|
{
|
||||||
|
// Chunki streamowania
|
||||||
|
inline constexpr uint32_t chunk_stream = 268435456; // 256MB
|
||||||
|
|
||||||
// Metody zapisania pliku
|
// Blok chunków
|
||||||
#define RAW_FILE 0
|
inline constexpr uint32_t block_size = 131072; // 128KB
|
||||||
#define ZIP_FILE 1
|
|
||||||
#define CRYPT_FILE 2
|
// Maksymalny rozmiar pliku do spakowania
|
||||||
#define CRYPT_ZIP 3
|
inline constexpr uint64_t maxFileSize = 8589934592; // 8GB
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flagi
|
||||||
|
namespace flag
|
||||||
|
{
|
||||||
|
inline constexpr uint8_t raw = 0x00; // Surowy plik
|
||||||
|
inline constexpr uint8_t zip = 0x0F; // Kompresja
|
||||||
|
inline constexpr uint8_t enc = 0xF0; // Szyfrowanie
|
||||||
|
inline constexpr uint8_t ezd = 0xFF; // Kompresja z szyfrowaniem
|
||||||
|
|
||||||
|
// Flaga do aktywacji filtra zdefiniowanego w json
|
||||||
|
inline constexpr uint8_t filter = 0xAB;
|
||||||
|
}
|
||||||
|
|
||||||
struct CargoHead
|
struct CargoHead
|
||||||
{
|
{
|
||||||
std::string signature;
|
std::string signature;
|
||||||
uint16_t version;
|
uint8_t version;
|
||||||
uint32_t files;
|
|
||||||
uint64_t table;
|
uint64_t table;
|
||||||
|
uint32_t files;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FilesTable
|
struct FilesTable
|
||||||
{
|
{
|
||||||
uint8_t nameLen;
|
uint8_t nameLen;
|
||||||
std::string nameFile;
|
std::string nameFile;
|
||||||
uint64_t hashName;
|
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
uint32_t size;
|
uint64_t size;
|
||||||
uint64_t crc;
|
uint64_t crc;
|
||||||
uint8_t isZip;
|
uint8_t flag;
|
||||||
};
|
};
|
||||||
|
|
@ -1,3 +1,22 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "EncryptionManager.h"
|
#include "EncryptionManager.h"
|
||||||
|
|
||||||
EncryptionManager::EncryptionManager()
|
EncryptionManager::EncryptionManager()
|
||||||
|
|
@ -8,47 +27,46 @@ EncryptionManager::EncryptionManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
keyReady = false;
|
keyReady = false;
|
||||||
|
generateKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> EncryptionManager::encrypt(const std::vector<char>& raw)
|
std::vector<char> EncryptionManager::encrypt(const std::vector<char>& raw)
|
||||||
{
|
{
|
||||||
std::vector<char> crypt(raw.size());
|
std::array<uint8_t, crypto_stream_chacha20_ietf_NONCEBYTES> nonce_local;
|
||||||
|
randombytes_buf(nonce_local.data(), nonce_local.size());
|
||||||
// Generowanie kluczy
|
|
||||||
generateKeys();
|
|
||||||
|
|
||||||
|
std::vector<char> tmp(raw.size());
|
||||||
if (crypto_stream_chacha20_ietf_xor_ic(
|
if (crypto_stream_chacha20_ietf_xor_ic(
|
||||||
reinterpret_cast<unsigned char*>(crypt.data()),
|
reinterpret_cast<unsigned char*>(tmp.data()),
|
||||||
reinterpret_cast<const unsigned char*>(raw.data()),
|
reinterpret_cast<const unsigned char*>(raw.data()),
|
||||||
static_cast<unsigned long long>(raw.size()),
|
static_cast<uint64_t>(raw.size()),
|
||||||
nonce.data(), 0, key.data()) != 0)
|
nonce_local.data(), 0, key.data()) != 0)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("crypto_stream_chacha20_ietf_xor_ic failed");
|
throw std::runtime_error("crypto_stream_chacha20_ietf_xor_ic failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return crypt;
|
std::vector<char> output;
|
||||||
|
output.insert(output.end(),
|
||||||
|
reinterpret_cast<const char*>(nonce_local.data()),
|
||||||
|
reinterpret_cast<const char*>(nonce_local.data()) + nonce_local.size());
|
||||||
|
|
||||||
|
output.insert(output.end(), tmp.begin(), tmp.end());
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncryptionManager::generateKeys()
|
void EncryptionManager::generateKeys()
|
||||||
{
|
{
|
||||||
if (keyReady) return;
|
if (keyReady) return;
|
||||||
|
|
||||||
std::cout << "GENEROWANIE KLUCZA" << std::endl;
|
|
||||||
|
|
||||||
//randombytes_buf(key.data(), key.size());
|
//randombytes_buf(key.data(), key.size());
|
||||||
crypto_stream_chacha20_ietf_keygen(key.data());
|
crypto_stream_chacha20_ietf_keygen(key.data());
|
||||||
randombytes_buf(nonce.data(), nonce.size());
|
|
||||||
|
|
||||||
keyReady = true;
|
keyReady = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncryptionManager::saveKey(const std::string& path)
|
void EncryptionManager::saveKey(const std::string& path, bool hpp)
|
||||||
{
|
{
|
||||||
std::cout << "ZAPISYWANIE KLUCZA" << std::endl;
|
|
||||||
|
|
||||||
const int sig = SIGNATURE_KEY_FILE;
|
|
||||||
const short ver = VERSION;
|
|
||||||
|
|
||||||
// Wygeneruj time stamp
|
// Wygeneruj time stamp
|
||||||
std::time_t now = std::time(nullptr);
|
std::time_t now = std::time(nullptr);
|
||||||
const int time = static_cast<int>(now);
|
const int time = static_cast<int>(now);
|
||||||
|
|
@ -57,111 +75,86 @@ void EncryptionManager::saveKey(const std::string& path)
|
||||||
std::vector<char> keyVec(reinterpret_cast<const char*>(key.data()),
|
std::vector<char> keyVec(reinterpret_cast<const char*>(key.data()),
|
||||||
reinterpret_cast<const char*>(key.data()) + key.size());
|
reinterpret_cast<const char*>(key.data()) + key.size());
|
||||||
|
|
||||||
std::vector<char> nonceVec(reinterpret_cast<const char*>(nonce.data()),
|
const uint64_t crcKey = XXH64(keyVec.data(), keyVec.size(), 0);
|
||||||
reinterpret_cast<const char*>(nonce.data()) + nonce.size());
|
|
||||||
|
|
||||||
const uint64_t crcKey = XXH64(keyVec.data(), keyVec.size(), VERSION);
|
|
||||||
const uint64_t crcNonce = XXH64(nonceVec.data(), nonceVec.size(), VERSION);
|
|
||||||
|
|
||||||
// Zapisz ten œmietnik do pliku KEY
|
// Zapisz ten œmietnik do pliku KEY
|
||||||
std::ofstream file(path + ".key", std::ios::binary);
|
std::ofstream file(path + ".key", std::ios::binary);
|
||||||
if (!file) { std::cout << "Dupa nie zapisa³o" << std::endl; }
|
if (!file) { std::cout << "Failed to save encryption key to file" << std::endl; }
|
||||||
|
|
||||||
file.write(reinterpret_cast<const char*>(&sig), sizeof(sig));
|
file.write(fl::sigkey.data(), fl::sigkey.length());
|
||||||
file.write(reinterpret_cast<const char*>(&ver), sizeof(ver));
|
|
||||||
file.write(reinterpret_cast<const char*>(&time), sizeof(time));
|
file.write(reinterpret_cast<const char*>(&time), sizeof(time));
|
||||||
file.write(reinterpret_cast<const char*>(keyVec.data()), keyVec.size());
|
file.write(reinterpret_cast<const char*>(keyVec.data()), keyVec.size());
|
||||||
file.write(reinterpret_cast<const char*>(&crcKey), sizeof(crcKey));
|
file.write(reinterpret_cast<const char*>(&crcKey), sizeof(crcKey));
|
||||||
file.write(reinterpret_cast<const char*>(nonceVec.data()), nonceVec.size());
|
|
||||||
file.write(reinterpret_cast<const char*>(&crcNonce), sizeof(crcNonce));
|
|
||||||
|
|
||||||
if (!file.good()) { std::cout << "Dupa nie zapisa³o" << std::endl; }
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
//saveCppHeadFile(path);
|
if (hpp) {saveCppHeadFile(path);}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generowanie pliku nag³ówkowego CPP z kluczem i nonce
|
// Generowanie pliku nag³ówkowego CPP z kluczem i nonce
|
||||||
void EncryptionManager::saveCppHeadFile(const std::string& path)
|
void EncryptionManager::saveCppHeadFile(const std::string& path)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> keyVec(key.begin(), key.end());
|
const uint32_t keySize = crypto_stream_chacha20_ietf_KEYBYTES;
|
||||||
std::vector<unsigned char> nonceVec(nonce.begin(), nonce.end());
|
|
||||||
|
|
||||||
const std::string headerText =
|
std::ofstream file(path + ".hpp");
|
||||||
"// Plik wygenerowany przy wykorzystaniu exPAK\n\n"
|
|
||||||
"// Klucz deszyfruj¹cy\n"
|
file << "// Plik wygenerowany przez " << ui::title << " " << ui::ver << std::endl;
|
||||||
"const std::array<unsigned char, crypto_stream_chacha20_ietf_KEYBYTES> key{" + toHex(keyVec) + "};\n\n"
|
file << std::endl;
|
||||||
"// Ci¹g nonce\n"
|
file << std::endl;
|
||||||
"const std::array<unsigned char, crypto_stream_chacha20_ietf_NONCEBYTES> nonce{" + toHex(nonceVec) + "}; ";
|
file << "#pragma once" << std::endl;
|
||||||
|
file << "#include <array>" << std::endl;
|
||||||
|
file << "#include <cstdint>" << std::endl;
|
||||||
|
file << std::endl;
|
||||||
|
file << "namespace enc" << std::endl;
|
||||||
|
file << "{" << std::endl;
|
||||||
|
file << " // Klucz deszyfruj¹cy" << std::endl;
|
||||||
|
file << " const std::array<uint8_t, " << keySize << "> key{" << std::endl;
|
||||||
|
file << " " << toHex(key.data(), key.size()) << std::endl;
|
||||||
|
file << " };" << std::endl;
|
||||||
|
file << std::endl;
|
||||||
|
file << "} //namespace" << std::endl;
|
||||||
|
|
||||||
std::ofstream file(path + ".hh");
|
|
||||||
file << headerText;
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string EncryptionManager::toHex(const std::vector<unsigned char>& data)
|
std::string EncryptionManager::toHex(const unsigned char* data, size_t len)
|
||||||
{
|
{
|
||||||
std::string bytes;
|
std::ostringstream oss;
|
||||||
int sk = data.size();
|
oss << std::hex << std::setfill('0');
|
||||||
int skp = 1;
|
for (size_t i = 0; i < len; ++i) {
|
||||||
|
oss << "0x" << std::setw(2) << static_cast<int>(data[i]);
|
||||||
for (const auto& b : data)
|
if (i + 1 != len) oss << ", ";
|
||||||
{
|
if ((i + 1) % 12 == 0 && i + 1 != len) oss << "\n ";
|
||||||
std::stringstream ss;
|
|
||||||
ss << "0x" << std::hex << std::uppercase << std::setw(2) << std::setfill('0')
|
|
||||||
<< static_cast<int>(b);
|
|
||||||
|
|
||||||
bytes += "'";
|
|
||||||
bytes += ss.str();
|
|
||||||
bytes += "'";
|
|
||||||
|
|
||||||
if (skp < sk)
|
|
||||||
{
|
|
||||||
bytes += ", ";
|
|
||||||
skp++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return oss.str();
|
||||||
return bytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wczytaj klucz
|
// Wczytaj klucz
|
||||||
void EncryptionManager::loadKey(const std::string& path)
|
void EncryptionManager::loadKey(const std::string& path)
|
||||||
{
|
{
|
||||||
std::cout << "ODCZYT KLUCZA" << std::endl;
|
|
||||||
std::ifstream file(path + ".key", std::ios::binary);
|
std::ifstream file(path + ".key", std::ios::binary);
|
||||||
|
std::vector<char> sig(fl::sigkey.size());
|
||||||
int sig;
|
int8_t ver;
|
||||||
short ver;
|
|
||||||
int time;
|
int time;
|
||||||
|
|
||||||
// Wczytaj
|
// Wczytaj
|
||||||
file.read(reinterpret_cast<char*>(&sig), sizeof(sig));
|
file.read(sig.data(), sig.size());
|
||||||
file.read(reinterpret_cast<char*>(&ver), sizeof(ver));
|
|
||||||
|
|
||||||
// SprawdŸ czy plik klucza jest poprawny
|
// SprawdŸ czy plik klucza jest poprawny
|
||||||
if (sig != SIGNATURE_KEY_FILE || ver != VERSION)
|
if (std::string(sig.begin(), sig.end()) != fl::sigkey)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Invalid key file!");
|
throw std::runtime_error("Invalid key file!");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> keyVec(key.size());
|
std::vector<char> keyVec(key.size());
|
||||||
std::vector<char> nonceVec(nonce.size());
|
|
||||||
uint64_t crcKey;
|
uint64_t crcKey;
|
||||||
uint64_t crcNonce;
|
|
||||||
|
|
||||||
file.read(reinterpret_cast<char*>(&time), sizeof(time));
|
file.read(reinterpret_cast<char*>(&time), sizeof(time));
|
||||||
file.read(keyVec.data(), keyVec.size());
|
file.read(keyVec.data(), keyVec.size());
|
||||||
file.read(reinterpret_cast<char*>(&crcKey), sizeof(crcKey));
|
file.read(reinterpret_cast<char*>(&crcKey), sizeof(crcKey));
|
||||||
file.read(nonceVec.data(), nonceVec.size());
|
|
||||||
file.read(reinterpret_cast<char*>(&crcNonce), sizeof(crcNonce));
|
|
||||||
|
|
||||||
std::cout << crcKey << " - " << XXH64(keyVec.data(), keyVec.size(), VERSION) << std::endl;
|
|
||||||
|
|
||||||
// SprawdŸ integralnoœæ klucza
|
// SprawdŸ integralnoœæ klucza
|
||||||
if (XXH64(keyVec.data(), keyVec.size(), VERSION) != crcKey
|
if (XXH64(keyVec.data(), keyVec.size(), 0) != crcKey)
|
||||||
|| XXH64(nonceVec.data(), nonceVec.size(), VERSION) != crcNonce)
|
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Key integrity error!");
|
throw std::runtime_error("Key integrity error!");
|
||||||
}
|
}
|
||||||
|
|
@ -170,19 +163,29 @@ void EncryptionManager::loadKey(const std::string& path)
|
||||||
|
|
||||||
// Przekonwertuj vector na array
|
// Przekonwertuj vector na array
|
||||||
key = toArray<crypto_stream_chacha20_ietf_KEYBYTES>(keyVec);
|
key = toArray<crypto_stream_chacha20_ietf_KEYBYTES>(keyVec);
|
||||||
nonce = toArray<crypto_stream_chacha20_ietf_NONCEBYTES>(nonceVec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deszyfracja
|
// Deszyfracja
|
||||||
std::vector<char> EncryptionManager::decrypt(const std::vector<char>& crypt)
|
std::vector<char> EncryptionManager::decrypt(const std::vector<char>& crypt)
|
||||||
{
|
{
|
||||||
std::vector<char> raw(crypt.size());
|
const size_t cryptoSize = crypto_stream_chacha20_ietf_NONCEBYTES;
|
||||||
|
|
||||||
|
std::array<uint8_t, cryptoSize> nonce_local;
|
||||||
|
std::memcpy(nonce_local.data(),
|
||||||
|
reinterpret_cast<const uint8_t*>(crypt.data()), cryptoSize);
|
||||||
|
|
||||||
|
|
||||||
|
const size_t rawSize = crypt.size() - cryptoSize;
|
||||||
|
std::vector<char> tmp(rawSize);
|
||||||
|
std::memcpy(tmp.data(), crypt.data() + cryptoSize, rawSize);
|
||||||
|
|
||||||
|
std::vector<char> raw(rawSize);
|
||||||
|
|
||||||
if (crypto_stream_chacha20_ietf_xor(
|
if (crypto_stream_chacha20_ietf_xor(
|
||||||
reinterpret_cast<unsigned char*>(raw.data()),
|
reinterpret_cast<unsigned char*>(raw.data()),
|
||||||
reinterpret_cast<const unsigned char*>(crypt.data()),
|
reinterpret_cast<const unsigned char*>(tmp.data()),
|
||||||
static_cast<unsigned long long>(crypt.size()),
|
static_cast<unsigned long long>(tmp.size()),
|
||||||
nonce.data(), key.data()) != 0)
|
nonce_local.data(), key.data()) != 0)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Data decryption error!");
|
throw std::runtime_error("Data decryption error!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,22 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
@ -23,16 +42,19 @@ public:
|
||||||
std::vector<char> encrypt(const std::vector<char>&);
|
std::vector<char> encrypt(const std::vector<char>&);
|
||||||
std::vector<char> decrypt(const std::vector<char>&);
|
std::vector<char> decrypt(const std::vector<char>&);
|
||||||
|
|
||||||
void saveKey(const std::string&);
|
void saveKey(const std::string&, bool);
|
||||||
void loadKey(const std::string&);
|
void loadKey(const std::string&);
|
||||||
|
|
||||||
|
// Generowanie hash BLAKE2b
|
||||||
|
//static std::array<char, 16> hashBlake(const std::vector<char>&);
|
||||||
|
//static bool compareBlake(const std::vector<char>&, const std::array<char, 16>&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<unsigned char, crypto_stream_chacha20_ietf_KEYBYTES> key{};
|
std::array<unsigned char, crypto_stream_chacha20_ietf_KEYBYTES> key{};
|
||||||
std::array<unsigned char, crypto_stream_chacha20_ietf_NONCEBYTES> nonce{};
|
|
||||||
bool keyReady;
|
bool keyReady;
|
||||||
|
|
||||||
void generateKeys();
|
void generateKeys();
|
||||||
std::string toHex(const std::vector<unsigned char>&);
|
std::string toHex(const unsigned char*, size_t);
|
||||||
void saveCppHeadFile(const std::string&);
|
void saveCppHeadFile(const std::string&);
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
|
|
|
||||||
127
ExtractCargo.cpp
127
ExtractCargo.cpp
|
|
@ -22,12 +22,11 @@
|
||||||
ExtractCargo::ExtractCargo()
|
ExtractCargo::ExtractCargo()
|
||||||
:filesLen(0)
|
:filesLen(0)
|
||||||
, tablePosition(0)
|
, tablePosition(0)
|
||||||
, filesHeadsOffset(0)
|
, xxhState(XXH64_createState())
|
||||||
, version(VERSION)
|
, signature(fl::sigpak)
|
||||||
, signature(SIGNATURE)
|
|
||||||
{
|
{
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
|
XXH64_reset(xxhState, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractCargo::~ExtractCargo()
|
ExtractCargo::~ExtractCargo()
|
||||||
|
|
@ -45,6 +44,8 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
||||||
{
|
{
|
||||||
cargoFileName = cFile;
|
cargoFileName = cFile;
|
||||||
|
|
||||||
|
std::cout << "START EXTRACT " << cFile << std::endl;
|
||||||
|
|
||||||
//Sprawdź czy plik istnieje
|
//Sprawdź czy plik istnieje
|
||||||
if (!std::filesystem::exists(cargoFileName))
|
if (!std::filesystem::exists(cargoFileName))
|
||||||
{
|
{
|
||||||
|
|
@ -60,8 +61,12 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wczytaj klucz deszyfrujący
|
// Wczytaj klucz deszyfrujący
|
||||||
//std::filesystem::path kdir = cargoFileName.stem();
|
std::filesystem::path kdir = cargoFileName.stem();
|
||||||
//eman.loadKey(kdir.string());
|
if (std::filesystem::exists(kdir.string() + ".key"))
|
||||||
|
{
|
||||||
|
std::cout << "Decryption key detected" << std::endl;
|
||||||
|
eman.loadKey(kdir.string());
|
||||||
|
}
|
||||||
|
|
||||||
//Otwieranie kontenera
|
//Otwieranie kontenera
|
||||||
cargoFile.open(cargoFileName, std::ios::binary);
|
cargoFile.open(cargoFileName, std::ios::binary);
|
||||||
|
|
@ -83,7 +88,7 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
||||||
bool ExtractCargo::CheckCargoFile()
|
bool ExtractCargo::CheckCargoFile()
|
||||||
{
|
{
|
||||||
std::vector<char> magic(signature.size());
|
std::vector<char> magic(signature.size());
|
||||||
uint16_t cargoVer = 0;
|
int8_t cargoVer = 0;
|
||||||
|
|
||||||
if (!cargoFile.is_open())
|
if (!cargoFile.is_open())
|
||||||
{
|
{
|
||||||
|
|
@ -92,40 +97,15 @@ bool ExtractCargo::CheckCargoFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
cargoFile.read(magic.data(), magic.size());
|
cargoFile.read(magic.data(), magic.size());
|
||||||
cargoFile.read(reinterpret_cast<char*>(&cargoVer), sizeof(cargoVer));
|
|
||||||
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)
|
if (std::string(magic.begin(), magic.end()) != signature)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cargoVer != version)
|
// Pobierz pozycjê tablicy plików i jej rozmiar
|
||||||
{
|
cargoFile.read(reinterpret_cast<char*>(&tablePosition), sizeof(tablePosition));
|
||||||
std::cerr << "Error: Wrong cargo version" << std::endl;
|
cargoFile.read(reinterpret_cast<char*>(&filesLen), sizeof(filesLen));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
filesHeadsOffset = signature.length() + sizeof(cargoVer) + sizeof(filesLen);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Sprawdzanie sumy kontrolnej
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool ExtractCargo::HashValid(const std::vector<char>& data, const uint64_t& crc)
|
|
||||||
{
|
|
||||||
uint64_t actualCrc = XXH64(data.data(), data.size(), VERSION);
|
|
||||||
|
|
||||||
if (actualCrc != crc)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +116,6 @@ bool ExtractCargo::HashValid(const std::vector<char>& data, const uint64_t& crc)
|
||||||
void ExtractCargo::LoadFilesTable()
|
void ExtractCargo::LoadFilesTable()
|
||||||
{
|
{
|
||||||
cargoFile.seekg(tablePosition);
|
cargoFile.seekg(tablePosition);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < filesLen; ++i)
|
for (uint32_t i = 0; i < filesLen; ++i)
|
||||||
{
|
{
|
||||||
FilesTable fhTmp;
|
FilesTable fhTmp;
|
||||||
|
|
@ -146,11 +125,10 @@ void ExtractCargo::LoadFilesTable()
|
||||||
cargoFile.read(nameBuffor.data(), fhTmp.nameLen);
|
cargoFile.read(nameBuffor.data(), fhTmp.nameLen);
|
||||||
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
||||||
|
|
||||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.hashName), sizeof(fhTmp.hashName));
|
|
||||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.offset), sizeof(fhTmp.offset));
|
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.size), sizeof(fhTmp.size));
|
||||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.crc), sizeof(fhTmp.crc));
|
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);
|
filesHeads.push_back(fhTmp);
|
||||||
}
|
}
|
||||||
|
|
@ -161,29 +139,80 @@ void ExtractCargo::LoadFilesTable()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void ExtractCargo::ExtractingFilesFromCargo()
|
void ExtractCargo::ExtractingFilesFromCargo()
|
||||||
{
|
{
|
||||||
CompressingManager cm;
|
|
||||||
|
|
||||||
for (const auto& fh : filesHeads)
|
for (const auto& fh : filesHeads)
|
||||||
{
|
{
|
||||||
std::filesystem::path dir = cargoFileName.stem() / fh.nameFile;
|
std::filesystem::path dir = cargoFileName.stem() / fh.nameFile;
|
||||||
CreateDirections(dir);
|
CreateDirections(dir);
|
||||||
|
|
||||||
|
std::cout << dir.string() << std::endl;
|
||||||
|
|
||||||
std::ofstream file(dir, std::ios::binary);
|
std::ofstream file(dir, std::ios::binary);
|
||||||
|
|
||||||
cargoFile.seekg(fh.offset);
|
cargoFile.seekg(fh.offset);
|
||||||
std::vector<char> buffor(fh.size);
|
|
||||||
|
|
||||||
cargoFile.read(buffor.data(), fh.size);
|
XXH64_reset(xxhState, 0);
|
||||||
|
|
||||||
std::vector<char> rawBuffor = fh.isZip ? cm.decompress(buffor) : eman.decrypt(buffor);
|
// Strumieñ wyci¹gaj¹cy
|
||||||
|
if (fh.flag == flag::raw)
|
||||||
if (!HashValid(rawBuffor, fh.crc))
|
|
||||||
{
|
{
|
||||||
std::cerr << fh.nameFile << " Error: Corrupted data integration CRC" << std::endl;
|
for (uint64_t sc = 0; sc < fh.size; sc += ds::chunk_stream)
|
||||||
|
{
|
||||||
|
const uint32_t streamChunk = std::min(ds::chunk_stream, static_cast<uint32_t>(fh.size - sc));
|
||||||
|
|
||||||
|
std::vector<char> buffer(streamChunk);
|
||||||
|
cargoFile.read(buffer.data(), streamChunk);
|
||||||
|
XXH64_update(xxhState, buffer.data(), buffer.size());
|
||||||
|
file.write(reinterpret_cast<const char*>(buffer.data()), streamChunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint32_t chunkLen;
|
||||||
|
uint32_t chunkBeforeSize;
|
||||||
|
uint32_t chunkLastSize;
|
||||||
|
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&chunkLen), sizeof(chunkLen));
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&chunkBeforeSize), sizeof(chunkBeforeSize));
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&chunkLastSize), sizeof(chunkLastSize));
|
||||||
|
|
||||||
|
std::vector<char> chunksString;
|
||||||
|
|
||||||
|
// Dekompresja bloków
|
||||||
|
for (size_t i = 0; i < chunkLen; ++i)
|
||||||
|
{
|
||||||
|
// Pobierz rozmiar chunków przed i po skompresowaniem
|
||||||
|
uint32_t chunkSize = i < chunkLen - 1 ? chunkBeforeSize : chunkLastSize;
|
||||||
|
|
||||||
|
uint32_t chunkZipSize;
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&chunkZipSize), sizeof(chunkZipSize));
|
||||||
|
|
||||||
|
// Pobierz blok chunka
|
||||||
|
std::vector<char> buffer(chunkZipSize);
|
||||||
|
cargoFile.read(buffer.data(), chunkZipSize);
|
||||||
|
|
||||||
|
std::vector<char> rawBuffer(chunkSize);
|
||||||
|
if ((fh.flag & flag::zip) == flag::zip)
|
||||||
|
{
|
||||||
|
rawBuffer = (fh.flag & flag::enc) == flag::enc ?
|
||||||
|
cman.decompress(eman.decrypt(buffer), chunkSize) :
|
||||||
|
cman.decompress(buffer, chunkSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rawBuffer = eman.decrypt(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
XXH64_update(xxhState, rawBuffer.data(), rawBuffer.size());
|
||||||
|
file.write(reinterpret_cast<const char*>(rawBuffer.data()), chunkSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.write(reinterpret_cast<const char*>(rawBuffor.data()), rawBuffor.size());
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
if (XXH64_digest(xxhState) != fh.crc)
|
||||||
|
{
|
||||||
|
std::cerr << dir.string() << " Error: Corrupted data integration CRC" << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Unpacking complete!" << std::endl;
|
std::cout << "Unpacking complete!" << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,12 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <xxhash.h>
|
#include <xxhash.h>
|
||||||
|
|
||||||
#include "DataStruct.h"
|
#include "DataStruct.h"
|
||||||
#include "CompressingManager.h"
|
|
||||||
#include "EncryptionManager.h"
|
#include "EncryptionManager.h"
|
||||||
|
#include "CompressionManager.h"
|
||||||
|
|
||||||
class ExtractCargo {
|
class ExtractCargo {
|
||||||
public:
|
public:
|
||||||
|
|
@ -47,9 +48,8 @@ private:
|
||||||
|
|
||||||
uint32_t filesLen;
|
uint32_t filesLen;
|
||||||
uint64_t tablePosition;
|
uint64_t tablePosition;
|
||||||
uint8_t filesHeadsOffset;
|
XXH64_state_t* xxhState;
|
||||||
|
|
||||||
const uint8_t version;
|
|
||||||
const std::string signature;
|
const std::string signature;
|
||||||
|
|
||||||
std::vector<FilesTable> filesHeads;
|
std::vector<FilesTable> filesHeads;
|
||||||
|
|
@ -58,7 +58,7 @@ private:
|
||||||
std::ifstream cargoFile;
|
std::ifstream cargoFile;
|
||||||
|
|
||||||
EncryptionManager eman;
|
EncryptionManager eman;
|
||||||
|
CompressionManager cman;
|
||||||
|
|
||||||
// Sprawdzenie poprawnoœci archiwum
|
// Sprawdzenie poprawnoœci archiwum
|
||||||
bool CheckCargoFile();
|
bool CheckCargoFile();
|
||||||
|
|
@ -69,9 +69,6 @@ private:
|
||||||
// Pobieranie nag³ówków plików
|
// Pobieranie nag³ówków plików
|
||||||
void LoadFilesTable();
|
void LoadFilesTable();
|
||||||
|
|
||||||
// Sprawdzanie sumy kontrolnej
|
|
||||||
bool HashValid(const std::vector<char>&, const uint64_t&);
|
|
||||||
|
|
||||||
// Utwórz katalog
|
// Utwórz katalog
|
||||||
void CreateDirections(std::filesystem::path);
|
void CreateDirections(std::filesystem::path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
#include "Interface.h"
|
|
||||||
|
|
||||||
Interface::Interface() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Interface::~Interface() {
|
|
||||||
// TODO Auto-generated destructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
void Interface::TextBorder(const std::string& title, const std::string& text)
|
|
||||||
{
|
|
||||||
auto element = ftxui::window(ftxui::text(title), ftxui::paragraphAlignLeft(text));
|
|
||||||
auto screen = ftxui::Screen::Create(ftxui::Dimension::Fit(element));
|
|
||||||
ftxui::Render(screen, element);
|
|
||||||
screen.Print();
|
|
||||||
}
|
|
||||||
14
Interface.h
14
Interface.h
|
|
@ -1,14 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ftxui/dom/elements.hpp>
|
|
||||||
#include <ftxui/screen/screen.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class Interface {
|
|
||||||
public:
|
|
||||||
Interface();
|
|
||||||
virtual ~Interface();
|
|
||||||
|
|
||||||
void TextBorder(const std::string&, const std::string&);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -91,7 +91,9 @@
|
||||||
|
|
||||||
**libsodium - https://github.com/jedisct1/libsodium**
|
**libsodium - https://github.com/jedisct1/libsodium**
|
||||||
|
|
||||||
**LZ4 - https://github.com/lz4/lz4.git**
|
**xxHash - https://github.com/Cyan4973/xxHash.git**
|
||||||
|
|
||||||
|
**Zstd - https://github.com/facebook/zstd.git**
|
||||||
|
|
||||||
**FTXUI - https://github.com/ArthurSonzogni/FTXUI.git**
|
**FTXUI - https://github.com/ArthurSonzogni/FTXUI.git**
|
||||||
|
|
||||||
|
|
|
||||||
71
Tui.cpp
Normal file
71
Tui.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Tui.h"
|
||||||
|
|
||||||
|
Tui::Tui() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Tui::~Tui() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tui::TextBorder(const std::string& title, const std::string& text)
|
||||||
|
{
|
||||||
|
auto element = ftxui::window(ftxui::text(title), ftxui::paragraphAlignLeft(text));
|
||||||
|
auto screen = ftxui::Screen::Create(ftxui::Dimension::Fit(element));
|
||||||
|
ftxui::Render(screen, element);
|
||||||
|
screen.Print();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tui::table(const std::vector<std::vector<std::string>>& data)
|
||||||
|
{
|
||||||
|
ftxui::Table table(data);
|
||||||
|
|
||||||
|
// Styl ogólny tabeli (ramki)
|
||||||
|
table.SelectAll().Border(ftxui::LIGHT);
|
||||||
|
|
||||||
|
// Oddzielenie nag³ówka od danych podwójn¹ lini¹
|
||||||
|
table.SelectRow(0).Border(ftxui::LIGHT);
|
||||||
|
table.SelectRow(0).Decorate(ftxui::bold); // Pogrubienie nag³ówka
|
||||||
|
table.SelectRow(0).SeparatorVertical(ftxui::LIGHT);
|
||||||
|
table.SelectRow(0).Border(ftxui::LIGHT);
|
||||||
|
|
||||||
|
table.SelectColumn(0).DecorateCells(ftxui::center);
|
||||||
|
table.SelectColumn(1).DecorateCells(ftxui::center);
|
||||||
|
|
||||||
|
table.SelectColumn(2).DecorateCells([](ftxui::Element e) {
|
||||||
|
return e | ftxui::flex;
|
||||||
|
});
|
||||||
|
|
||||||
|
table.SelectColumn(3).DecorateCells(ftxui::center);
|
||||||
|
|
||||||
|
table.SelectColumn(0).BorderRight(ftxui::LIGHT);
|
||||||
|
table.SelectColumn(1).BorderRight(ftxui::LIGHT);
|
||||||
|
table.SelectColumn(2).BorderRight(ftxui::LIGHT);
|
||||||
|
|
||||||
|
auto document = table.Render();
|
||||||
|
|
||||||
|
auto screen = ftxui::Screen::Create(ftxui::Dimension::Full(), ftxui::Dimension::Fit(document));
|
||||||
|
|
||||||
|
ftxui::Render(screen, document);
|
||||||
|
screen.Print();
|
||||||
|
}
|
||||||
34
Tui.h
Normal file
34
Tui.h
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ftxui/dom/elements.hpp>
|
||||||
|
#include <ftxui/dom/table.hpp>
|
||||||
|
#include <ftxui/screen/screen.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Tui {
|
||||||
|
public:
|
||||||
|
Tui();
|
||||||
|
virtual ~Tui();
|
||||||
|
|
||||||
|
void TextBorder(const std::string&, const std::string&);
|
||||||
|
void table(const std::vector<std::vector<std::string>>&);
|
||||||
|
};
|
||||||
174
Txtpp.h
174
Txtpp.h
|
|
@ -1,174 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <filesystem>
|
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
class Txtpp {
|
|
||||||
public:
|
|
||||||
Txtpp(const std::string& path = "")
|
|
||||||
{
|
|
||||||
if (path != "")
|
|
||||||
{
|
|
||||||
Load(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~Txtpp()
|
|
||||||
{
|
|
||||||
if (file.is_open())
|
|
||||||
{
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Load(const std::string& path)
|
|
||||||
{
|
|
||||||
if (!std::filesystem::exists(path))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.open(path);
|
|
||||||
|
|
||||||
return file.is_open();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Close()
|
|
||||||
{
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> Get(const std::string& key)
|
|
||||||
{
|
|
||||||
std::vector<std::string> tmp;
|
|
||||||
Parse(key, tmp);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T getValue(const std::string& key, const std::string& val)
|
|
||||||
{
|
|
||||||
std::vector<std::string> tmp;
|
|
||||||
Parse(key, tmp);
|
|
||||||
|
|
||||||
for (const auto& line : tmp)
|
|
||||||
{
|
|
||||||
std::string cleanLine = RemoveSpaces(line);
|
|
||||||
std::string t;
|
|
||||||
std::string v;
|
|
||||||
|
|
||||||
bool tv = false;
|
|
||||||
|
|
||||||
for (const char& c : cleanLine)
|
|
||||||
{
|
|
||||||
if (c != ":") {tv = true;}
|
|
||||||
|
|
||||||
if (!tv) { t += c; }
|
|
||||||
else { v += c; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char sectionStart = '{';
|
|
||||||
const char sectionEnd = '}';
|
|
||||||
|
|
||||||
std::ifstream file;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Wyszukiwanie danych po kluczu
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Parse(const std::string& key, std::vector<std::string>& data)
|
|
||||||
{
|
|
||||||
std::string fullkey = sectionStart + key + sectionEnd;
|
|
||||||
std::string line;
|
|
||||||
bool wr = false;
|
|
||||||
|
|
||||||
file.clear();
|
|
||||||
file.seekg(std::ios::beg);
|
|
||||||
|
|
||||||
while (getline(file, line))
|
|
||||||
{
|
|
||||||
std::string tmp = RemoveSpaces(line);
|
|
||||||
if (tmp != "")
|
|
||||||
{
|
|
||||||
if (CheckKey(tmp))
|
|
||||||
{
|
|
||||||
wr = UpperString(tmp) == fullkey ? true : false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (wr) { data.push_back(tmp); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Usuwa spacje
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
std::string RemoveSpaces(std::string _line)
|
|
||||||
{
|
|
||||||
std::stringstream ss(_line);
|
|
||||||
char word;
|
|
||||||
std::string tmp;
|
|
||||||
std::string beforeWord = "";
|
|
||||||
|
|
||||||
while (ss >> word)
|
|
||||||
{
|
|
||||||
tmp += word;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Sprawdza czy dany ci¹g jest kluczem
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool CheckKey(std::string key)
|
|
||||||
{
|
|
||||||
if (key[0] == sectionStart && key[key.length() - 1])
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Zamieñ ca³y ci¹g na du¿e litery
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
std::string UpperString(std::string s) {
|
|
||||||
std::transform(s.begin(), s.end(), s.begin(),
|
|
||||||
[](unsigned char c) { return static_cast<char>(std::toupper(c)); });
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
142
ViewCargo.cpp
142
ViewCargo.cpp
|
|
@ -20,14 +20,7 @@
|
||||||
#include "ViewCargo.h"
|
#include "ViewCargo.h"
|
||||||
|
|
||||||
ViewCargo::ViewCargo()
|
ViewCargo::ViewCargo()
|
||||||
:signature(SIGNATURE)
|
{}
|
||||||
, version(VERSION)
|
|
||||||
, filesLen(0)
|
|
||||||
, tablePos(0)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Wywoływanie
|
// Wywoływanie
|
||||||
|
|
@ -49,38 +42,25 @@ bool ViewCargo::View(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sprawdź czy kontener jest prawidłowy
|
//Sprawdź czy kontener jest prawidłowy
|
||||||
if (!CheckCargoFile(path))
|
if (!ViewFiles(path))
|
||||||
{
|
{
|
||||||
std::cerr << "Nie prawidlowa struktura kontenera Void" << std::endl;
|
std::cerr << "Nie prawidlowa struktura kontenera Void" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Table Header
|
|
||||||
std::vector<ftxui::Element> headElements;
|
|
||||||
|
|
||||||
headElements.push_back(ftxui::text(" Zip ") | ftxui::bold);
|
|
||||||
headElements.push_back(ftxui::text("Nazwa pliku") | ftxui::bold | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 56));
|
|
||||||
headElements.push_back(ftxui::text("Hash Name") | ftxui::bold | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 20));
|
|
||||||
|
|
||||||
filesList.push_back(hbox(std::move(headElements)));
|
|
||||||
|
|
||||||
|
|
||||||
//Pobieranie listy plików
|
|
||||||
GetFileList(path);
|
|
||||||
|
|
||||||
//Renderowanie listy plików
|
|
||||||
RenderList();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Sprawdzenie poprawności kontenera
|
// Sprawdzenie poprawności kontenera
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool ViewCargo::CheckCargoFile(const std::string& path)
|
bool ViewCargo::ViewFiles(const std::string& path)
|
||||||
{
|
{
|
||||||
std::vector<char> magic(signature.length());
|
uint64_t tabPos = 0;
|
||||||
uint16_t cargoVer = 0;
|
uint32_t tabSize = 0;
|
||||||
|
|
||||||
|
std::vector<char> magic(fl::sigpak.length());
|
||||||
|
int8_t cargoVer = 0;
|
||||||
|
|
||||||
std::ifstream cargo(path, std::ios::binary);
|
std::ifstream cargo(path, std::ios::binary);
|
||||||
|
|
||||||
|
|
@ -91,46 +71,30 @@ bool ViewCargo::CheckCargoFile(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Odczytywanie pierwszych 11 bajtów nag³ówka pliku
|
// Odczytywanie pierwszych 16 bajtów nag³ówka pliku
|
||||||
// 6 pierwszych to sygnatura
|
// 4 Sygnatura kontenera XPAK
|
||||||
// 1 wersja kontenera
|
// 8 Offset tablicy plików
|
||||||
// 4 iloœæ plików w kontenerze
|
// 4 Rozmiar tablicy plików
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
cargo.read(magic.data(), magic.size());
|
cargo.read(magic.data(), magic.size());
|
||||||
cargo.read(reinterpret_cast<char*>(&cargoVer), sizeof(cargoVer));
|
cargo.read(reinterpret_cast<char*>(&tabPos), sizeof(tabPos));
|
||||||
cargo.read(reinterpret_cast<char*>(&filesLen), sizeof(filesLen));
|
cargo.read(reinterpret_cast<char*>(&tabSize), sizeof(tabSize));
|
||||||
cargo.read(reinterpret_cast<char*>(&tablePos), sizeof(tablePos));
|
|
||||||
|
|
||||||
//Sprawdź czy kontener ma poprawną sygnature
|
//Sprawdź czy kontener ma poprawną sygnature
|
||||||
if (std::string(magic.begin(), magic.end()) != signature)
|
if (std::string(magic.begin(), magic.end()) != fl::sigpak)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||||
cargo.close();
|
cargo.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//SprawdŸ spójnoœæ wersji kontenera
|
std::cout << "ZIP" << " " << "ENC" << " " << "Path" << std::endl;
|
||||||
if (cargoVer != version)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: Wrong cargo version" << std::endl;
|
|
||||||
cargo.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
cargo.close();
|
// Przeskocz do tablicy plików
|
||||||
|
cargo.seekg(tabPos);
|
||||||
|
|
||||||
return true;
|
// Za³aduj dane o plikach
|
||||||
}
|
for (uint32_t i = 0; i < tabSize; ++i)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Pobieranie listy plików z kontenera
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ViewCargo::GetFileList(const std::string& path)
|
|
||||||
{
|
|
||||||
std::ifstream cargo(path, std::ios::binary);
|
|
||||||
cargo.seekg(tablePos);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < filesLen; ++i)
|
|
||||||
{
|
{
|
||||||
FilesTable fhTmp;
|
FilesTable fhTmp;
|
||||||
cargo.read(reinterpret_cast<char*>(&fhTmp.nameLen), sizeof(fhTmp.nameLen));
|
cargo.read(reinterpret_cast<char*>(&fhTmp.nameLen), sizeof(fhTmp.nameLen));
|
||||||
|
|
@ -139,60 +103,50 @@ void ViewCargo::GetFileList(const std::string& path)
|
||||||
cargo.read(nameBuffor.data(), fhTmp.nameLen);
|
cargo.read(nameBuffor.data(), fhTmp.nameLen);
|
||||||
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
||||||
|
|
||||||
cargo.read(reinterpret_cast<char*>(&fhTmp.hashName), sizeof(fhTmp.hashName));
|
|
||||||
cargo.read(reinterpret_cast<char*>(&fhTmp.offset), sizeof(fhTmp.offset));
|
cargo.read(reinterpret_cast<char*>(&fhTmp.offset), sizeof(fhTmp.offset));
|
||||||
cargo.read(reinterpret_cast<char*>(&fhTmp.size), sizeof(fhTmp.size));
|
cargo.read(reinterpret_cast<char*>(&fhTmp.size), sizeof(fhTmp.size));
|
||||||
cargo.read(reinterpret_cast<char*>(&fhTmp.crc), sizeof(fhTmp.crc));
|
cargo.read(reinterpret_cast<char*>(&fhTmp.crc), sizeof(fhTmp.crc));
|
||||||
cargo.read(reinterpret_cast<char*>(&fhTmp.isZip), sizeof(fhTmp.isZip));
|
cargo.read(reinterpret_cast<char*>(&fhTmp.flag), sizeof(fhTmp.flag));
|
||||||
|
|
||||||
//Tworzenie wierszy tabeli
|
//Tworzenie wierszy tabeli
|
||||||
CreateTableRow(fhTmp.nameFile, fhTmp.isZip, fhTmp.hashName);
|
ShowFile(fhTmp.nameFile, fhTmp.flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo.close();
|
cargo.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Generowanie wierszy do tabeli
|
// Generowanie wierszy do tabeli
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void ViewCargo::CreateTableRow(const std::string& file, const uint8_t& zip, const uint64_t& hash)
|
void ViewCargo::ShowFile(const std::string& file, const uint8_t& flag)
|
||||||
{
|
{
|
||||||
//Zamiania crc liczbowej na hex string
|
std::string compresedCheck = "[ ]";
|
||||||
std::stringstream ss;
|
std::string encryptedCheck = "[ ]";
|
||||||
ss << "0x" << std::hex << std::uppercase << hash;
|
|
||||||
|
|
||||||
std::vector<ftxui::Element> cell;
|
// Ustawianie checkboxów
|
||||||
|
switch (flag)
|
||||||
ftxui::Element eZip;
|
|
||||||
|
|
||||||
//Dodawanie check boxa czy plik jest spakowany czy nie
|
|
||||||
if (zip == 1)
|
|
||||||
{
|
{
|
||||||
eZip = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Cyan);
|
case flag::zip:
|
||||||
}
|
compresedCheck = "[x]";
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
eZip = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::White);
|
case flag::enc:
|
||||||
|
encryptedCheck = "[x]";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case flag::ezd:
|
||||||
|
compresedCheck = "[x]";
|
||||||
|
encryptedCheck = "[x]";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
compresedCheck = "[ ]";
|
||||||
|
encryptedCheck = "[ ]";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dodawanie komurek
|
// Wyœwietlanie
|
||||||
cell.push_back(eZip);
|
std::cout << compresedCheck << " " << encryptedCheck << " " << file << std::endl;
|
||||||
cell.push_back(ftxui::text(file) | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 56));
|
|
||||||
cell.push_back(ftxui::text(ss.str()) | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 20));
|
|
||||||
|
|
||||||
//Konwersja komurek na wiersz
|
|
||||||
filesList.push_back(ftxui::hbox(std::move(cell)));
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Renderowanie listy plików
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ViewCargo::RenderList()
|
|
||||||
{
|
|
||||||
//Dodawanie wierszy do kolumn
|
|
||||||
ftxui::Element table = ftxui::vbox(std::move(filesList));
|
|
||||||
|
|
||||||
auto screen = ftxui::Screen::Create(ftxui::Dimension::Fit(table));
|
|
||||||
ftxui::Render(screen, table);
|
|
||||||
screen.Print();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
ViewCargo.h
14
ViewCargo.h
|
|
@ -27,6 +27,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <ftxui/dom/elements.hpp>
|
#include <ftxui/dom/elements.hpp>
|
||||||
#include <ftxui/screen/screen.hpp>
|
#include <ftxui/screen/screen.hpp>
|
||||||
|
#include <ftxui/dom/table.hpp>
|
||||||
|
|
||||||
#include "DataStruct.h"
|
#include "DataStruct.h"
|
||||||
|
|
||||||
|
|
@ -38,17 +39,8 @@ public:
|
||||||
bool View(const std::string&);
|
bool View(const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string signature;
|
bool ViewFiles(const std::string&);
|
||||||
const uint16_t version;
|
void ShowFile(const std::string&, const uint8_t&);
|
||||||
|
|
||||||
uint32_t filesLen;
|
|
||||||
uint64_t tablePos;
|
|
||||||
std::vector<ftxui::Element> filesList;
|
|
||||||
|
|
||||||
bool CheckCargoFile(const std::string&);
|
|
||||||
void GetFileList(const std::string&);
|
|
||||||
void RenderList();
|
|
||||||
void CreateTableRow(const std::string&, const uint8_t&, const uint64_t&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
21
license/FTXUI/LICENSE.txt
Normal file
21
license/FTXUI/LICENSE.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Arthur Sonzogni.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
This repository uses 2 different licenses :
|
|
||||||
- all files in the `lib` directory use a BSD 2-Clause license
|
|
||||||
- all other files use a GPL-2.0-or-later license, unless explicitly stated otherwise
|
|
||||||
|
|
||||||
Relevant license is reminded at the top of each source file,
|
|
||||||
and with presence of COPYING or LICENSE file in associated directories.
|
|
||||||
|
|
||||||
This model is selected to emphasize that
|
|
||||||
files in the `lib` directory are designed to be included into 3rd party applications,
|
|
||||||
while all other files, in `programs`, `tests` or `examples`,
|
|
||||||
are intended to be used "as is", as part of their intended scenarios,
|
|
||||||
with no intention to support 3rd party integration use cases.
|
|
||||||
30
license/zstd/LICENSE.txt
Normal file
30
license/zstd/LICENSE.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
BSD License
|
||||||
|
|
||||||
|
For Zstandard software
|
||||||
|
|
||||||
|
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name Facebook, nor Meta, nor the names of its contributors may
|
||||||
|
be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
BIN
testx/herrsher-of-the-void.png
Normal file
BIN
testx/herrsher-of-the-void.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 851 KiB |
BIN
testx/mus_honkai_space.ogg
Normal file
BIN
testx/mus_honkai_space.ogg
Normal file
Binary file not shown.
126
testx/text_file.txt
Normal file
126
testx/text_file.txt
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
Nam strzelać nie kazano. - Wstąpiłem na działo
|
||||||
|
I spójrzałem na pole; dwieście armat grzmiało.
|
||||||
|
Artyleryi ruskiej ciągną się szeregi,
|
||||||
|
Prosto, długo, daleko, jako morza brzegi;
|
||||||
|
I widziałem ich wodza: przybiegł, mieczem skinął
|
||||||
|
I jak ptak jedno skrzydło wojska swego zwinął;
|
||||||
|
Wylewa się spod skrzydła ściśniona piechota
|
||||||
|
Długą czarną kolumną, jako lawa błota,
|
||||||
|
Nasypana iskrami bagnetów. Jak sępy
|
||||||
|
Czarne chorągwie na śmierć prowadzą zastępy.
|
||||||
|
|
||||||
|
Przeciw nim sterczy biała, wąska, zaostrzona,
|
||||||
|
Jak głaz bodzący morze, reduta Ordona.
|
||||||
|
Sześć tylko miała armat; wciąż dymią i świecą;
|
||||||
|
I nie tyle prędkich słów gniewne usta miecą,
|
||||||
|
Nie tyle przejdzie uczuć przez duszę w rozpaczy,
|
||||||
|
Ile z tych dział leciało bomb, kul i kartaczy.
|
||||||
|
Patrz, tam granat w sam środek kolumny się nurza,
|
||||||
|
Jak w fale bryła lawy, pułk dymem zachmurza;
|
||||||
|
Pęka śród dymu granat, szyk pod niebo leci
|
||||||
|
I ogromna łysina śród kolumny świeci.
|
||||||
|
|
||||||
|
Tam kula, lecąc, z dala grozi, szumi, wyje.
|
||||||
|
Ryczy jak byk przed bitwą, miota się, grunt ryje; -
|
||||||
|
Już dopadła; jak boa śród kolumn się zwija,
|
||||||
|
Pali piersią, rwie zębem, oddechem zabija.
|
||||||
|
Najstraszniejszej nie widać, lecz słychać po dźwięku,
|
||||||
|
Po waleniu się trupów, po ranionych jęku:
|
||||||
|
Gdy kolumnę od końca do końca przewierci,
|
||||||
|
Jak gdyby środkiem wojska przeszedł anioł śmierci.
|
||||||
|
|
||||||
|
Gdzież jest król, co na rzezie tłumy te wyprawia?
|
||||||
|
Czy dzieli ich odwagę, czy pierś sam nadstawia?
|
||||||
|
Nie, on siedzi o pięćset mil na swej stolicy,
|
||||||
|
Król wielki, samowładnik świata połowicy;
|
||||||
|
Zmarszczył brwi, - i tysiące kibitek wnet leci;
|
||||||
|
Podpisał, - tysiąc matek opłakuje dzieci;
|
||||||
|
Skinął, - padają knuty od Niemna do Chiwy.
|
||||||
|
Mocarzu, jak Bóg silny, jak szatan złośliwy,
|
||||||
|
Gdy Turków za Bałkanem twoje straszą spiże,
|
||||||
|
Gdy poselstwo paryskie twoje stopy liże, -
|
||||||
|
Warszawa jedna twojej mocy się urąga,
|
||||||
|
Podnosi na cię rękę i koronę ściąga,
|
||||||
|
Koronę Kazimierzów, Chrobrych z twojej głowy,
|
||||||
|
Boś ją ukradł i skrwawił, synu Wasilowy!
|
||||||
|
|
||||||
|
Car dziwi się - ze strachu. drzą Petersburczany,
|
||||||
|
Car gniewa się - ze strachu mrą jego dworzany;
|
||||||
|
Ale sypią się wojska, których Bóg i wiara
|
||||||
|
Jest Car. - Car gniewny: umrzem, rozweselim Cara.
|
||||||
|
Posłany wódz kaukaski z siłami pół-świata,
|
||||||
|
Wierny, czynny i sprawny - jak knut w ręku kata.
|
||||||
|
|
||||||
|
Ura! ura! Patrz, blisko reduty, już w rowy
|
||||||
|
Walą się, na faszynę kładąc swe tułowy;
|
||||||
|
Już czernią się na białych palisadach wałów.
|
||||||
|
Jeszcze reduta w środku, jasna od wystrzałów,
|
||||||
|
Czerwieni się nad czernią: jak w środek mrowiaka
|
||||||
|
Wrzucony motyl błyska, - mrowie go naciska, -
|
||||||
|
Zgasł - tak zgasła reduta. Czyż ostatnie działo
|
||||||
|
Strącone z łoża w piasku paszczę zagrzebało?
|
||||||
|
Czy zapał krwią ostatni bombardyjer zalał?
|
||||||
|
Zgasnął ogień. - Już Moskal rogatki wywalał.
|
||||||
|
|
||||||
|
Gdzież ręczna broń? - Ach, dzisiaj pracowała więcej
|
||||||
|
Niż na wszystkich przeglądach za władzy książęcej;
|
||||||
|
Zgadłem, dlaczego milczy, - bo nieraz widziałem
|
||||||
|
Garstkę naszych walczącą z Moskali nawałem.
|
||||||
|
Gdy godzinę wołano dwa słowa: pal, nabij;
|
||||||
|
Gdy oddechy dym tłumi, trud ramiona słabi;
|
||||||
|
A wciąż grzmi rozkaz wodzów, wre żołnierza czynność;
|
||||||
|
Na koniec bez rozkazu pełnią swą powinność,
|
||||||
|
Na koniec bez rozwagi, bez czucia, pamięci,
|
||||||
|
Żołnierz jako młyn palny nabija - grzmi - kręci
|
||||||
|
Broń od oka do nogi, od nogi na oko:
|
||||||
|
Aż ręka w ładownicy długo i głęboko
|
||||||
|
Szukała, nie znalazła - i żołnierz pobladnął,
|
||||||
|
Nie znalazłszy ładunku, już bronią nie władnął;
|
||||||
|
I uczuł, że go pali strzelba rozogniona;
|
||||||
|
Upuścił ją i upadł; - nim dobiją, skona.
|
||||||
|
Takem myślił, - a w szaniec nieprzyjaciół kupa
|
||||||
|
Już łazła, jak robactwo na świeżego trupa.
|
||||||
|
|
||||||
|
Pociemniało mi w oczach - a gdym łzy ocierał,
|
||||||
|
Słyszałem, że coś do mnie mówił mój Jenerał.
|
||||||
|
On przez lunetę wspartą na moim ramieniu
|
||||||
|
Długo na szturm i szaniec poglądał w milczeniu.
|
||||||
|
Na koniec rzekł; "Stracona". - Spod lunety jego
|
||||||
|
Wymknęło się łez kilka, - rzekł do mnie: "Kolego,
|
||||||
|
Wzrok młody od szkieł lepszy; patrzaj, tam na wale,
|
||||||
|
Znasz Ordona, czy widzisz, gdzie jest?" - "Jenerale,
|
||||||
|
Czy go znam? - Tam stał zawsze, to działo kierował.
|
||||||
|
Nie widzę - znajdę - dojrzę! - śród dymu się schował:
|
||||||
|
Lecz śród najgęstszych kłębów dymu ileż razy
|
||||||
|
Widziałem rękę jego, dającą rozkazy. -
|
||||||
|
Widzę go znowu, - widzę rękę - błyskawicę,
|
||||||
|
Wywija, grozi wrogom, trzyma palną świécę,
|
||||||
|
Biorą go - zginął - o nie, - skoczył w dół, - do lochów"!
|
||||||
|
"Dobrze - rzecze Jenerał - nie odda im prochów".
|
||||||
|
|
||||||
|
Tu blask - dym - chwila cicho - i huk jak stu gromów.
|
||||||
|
Zaćmiło się powietrze od ziemi wylomów,
|
||||||
|
Harmaty podskoczyły i jak wystrzelone
|
||||||
|
Toczyły się na kołach - lonty zapalone
|
||||||
|
Nie trafiły do swoich panew. I dym wionął
|
||||||
|
Prosto ku nam; i w gęstej chmurze nas ochłonął.
|
||||||
|
I nie było nic widać prócz granatów blasku
|
||||||
|
I powoli dym rzedniał, opadał deszcz piasku.
|
||||||
|
Spojrzałem na redutę; - wały, palisady,
|
||||||
|
Działa i naszych garstka, i wrogów gromady;
|
||||||
|
Wszystko jako sen znikło. - Tylko czarna bryła
|
||||||
|
Ziemi niekształtnej leży - rozjemcza mogiła.
|
||||||
|
Tam i ci, co bronili, -i ci, co się wdarli,
|
||||||
|
Pierwszy raz pokój szczery i wieczny zawarli.
|
||||||
|
Choćby cesarz Moskalom kazał wstać, już dusza
|
||||||
|
Moskiewska. tam raz pierwszy, cesarza nie słusza.
|
||||||
|
Tam zagrzebane tylu set ciała, imiona:
|
||||||
|
Dusze gdzie? nie wiem; lecz wiem, gdzie dusza Ordona.
|
||||||
|
On będzie Patron szańców! - Bo dzieło zniszczenia
|
||||||
|
W dobrej sprawie jest święte, Jak dzieło tworzenia;
|
||||||
|
Bóg wyrzekł słowo stań się, Bóg i zgiń wyrzecze.
|
||||||
|
Kiedy od ludzi wiara i wolność uciecze,
|
||||||
|
Kiedy ziemię despotyzm i duma szalona
|
||||||
|
Obleją, jak Moskale redutę Ordona -
|
||||||
|
Karząc plemię zwyciężców zbrodniami zatrute,
|
||||||
|
Bóg wysadzi tę ziemię, jak on swą redutę.
|
||||||
79
voidcmd.cpp
79
voidcmd.cpp
|
|
@ -32,7 +32,7 @@
|
||||||
#include "CreateCargo.h"
|
#include "CreateCargo.h"
|
||||||
#include "ExtractCargo.h"
|
#include "ExtractCargo.h"
|
||||||
#include "ViewCargo.h"
|
#include "ViewCargo.h"
|
||||||
#include "Interface.h"
|
#include "Tui.h"
|
||||||
|
|
||||||
void RenderHelp()
|
void RenderHelp()
|
||||||
{
|
{
|
||||||
|
|
@ -40,36 +40,35 @@ void RenderHelp()
|
||||||
const std::string HelpInstruction =
|
const std::string HelpInstruction =
|
||||||
"pakcmd <parametr> <catalog> \n"
|
"pakcmd <parametr> <catalog> \n"
|
||||||
" \n"
|
" \n"
|
||||||
" -c Pack and compress with LZ4 \n"
|
" -c Compressing \n"
|
||||||
" -p Pack files from the specified directory \n"
|
" -r Raw files \n"
|
||||||
" -e Pack and encrypted from the specified directory \n"
|
" -e Encrypted \n"
|
||||||
" -f Pack the files according to the guidelines given in the <directory>.txt \n"
|
" -s Compressing and Encrypted \n"
|
||||||
" -s Pack and encrypted \n"
|
" -f Pack the files according to the guidelines given in the <directory>.json \n"
|
||||||
" -cs Pack and compress \n"
|
|
||||||
" \n"
|
" \n"
|
||||||
"Extracting: \n"
|
"Extracting: \n"
|
||||||
" -x Extract files from the specified container \n"
|
" -x Extract files from the specified container \n"
|
||||||
|
" \n"
|
||||||
|
"Others: \n"
|
||||||
" -ls List files stored in a container \n"
|
" -ls List files stored in a container \n"
|
||||||
" \n"
|
" \n"
|
||||||
" \n"
|
"<catalog>.json \n"
|
||||||
"<catalog>.txt \n"
|
|
||||||
" \n"
|
" \n"
|
||||||
"Keys: \n"
|
"Keys: \n"
|
||||||
" \n"
|
" \n"
|
||||||
" {compress} - Compressing files \n"
|
" {compress} - Compressing files \n"
|
||||||
" {crypt} - Encrypted files with ChaCha20 \n"
|
" {crypt} - Encrypted files \n"
|
||||||
" {ignore} - Ignoring concrete files \n"
|
" {ignore} - Ignoring concrete files \n"
|
||||||
" \n"
|
" \n"
|
||||||
" /path/to/file.ext - Concrete file \n"
|
" /path/to/file.ext - Concrete file \n"
|
||||||
" *.ext - All files with concrete extension \n"
|
" *.ext - All files with concrete extension \n"
|
||||||
" *.* - All files !NOT WORKING WITH {ignore} KEY! \n"
|
" *.* - All files !NOT WORKING WITH {ignore} KEY! \n";
|
||||||
" \n";
|
|
||||||
|
|
||||||
Interface tui;
|
//Interface tui;
|
||||||
tui.TextBorder(HelpTitle, HelpInstruction);
|
//tui.TextBorder(HelpTitle, HelpInstruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmptyPath(std::string path)
|
static bool EmptyPath(std::string path)
|
||||||
{
|
{
|
||||||
if (path == "")
|
if (path == "")
|
||||||
{
|
{
|
||||||
|
|
@ -81,26 +80,16 @@ bool EmptyPath(std::string path)
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string path = "";
|
std::cout << ui::title << std::endl << "ver. " << ui::ver << std::endl;
|
||||||
|
std::cout << "Author: Yanczi" << std::endl;
|
||||||
std::cout <<
|
std::cout << "License: GNU LGPL v3" << "\n" << std::endl;
|
||||||
" 8888888b. d8888 888 d8P \n"
|
|
||||||
" 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"
|
|
||||||
"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"
|
|
||||||
<< std::endl;
|
|
||||||
std::cout << "\n" << PROGRAM_VERSION << " Release " << PROGRAM_COMPILING << std::endl;
|
|
||||||
std::cout << "Author: " << PROGRAM_AUTHOR << std::endl;
|
|
||||||
std::cout << "License: " << PROGRAM_LICENSE << "\n" << std::endl;
|
|
||||||
|
|
||||||
CreateCargo cargo;
|
CreateCargo cargo;
|
||||||
ExtractCargo extract;
|
ExtractCargo extract;
|
||||||
ViewCargo viewCargo;
|
ViewCargo viewCargo;
|
||||||
|
|
||||||
|
std::string path = "";
|
||||||
|
|
||||||
for (int i = 0; i < argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
std::string arg = argv[i];
|
std::string arg = argv[i];
|
||||||
|
|
@ -111,17 +100,37 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
if (!EmptyPath(path)) { return 1; }
|
if (!EmptyPath(path)) { return 1; }
|
||||||
|
|
||||||
if (!cargo.Create(path, 1))
|
if (!cargo.Create(path, 0x0F))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg == "-p" && i + 1 < argc)
|
if (arg == "-r" && i + 1 < argc)
|
||||||
{
|
{
|
||||||
path = argv[i + 1];
|
path = argv[i + 1];
|
||||||
if (!cargo.Create(path, 0))
|
if (!cargo.Create(path, 0x00))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-e" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
if (!cargo.Create(path, 0xF0))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-s" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
if (!cargo.Create(path, 0xFF))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +141,7 @@ int main(int argc, char* argv[]) {
|
||||||
{
|
{
|
||||||
path = argv[i + 1];
|
path = argv[i + 1];
|
||||||
if (!EmptyPath(path)) { return 1; }
|
if (!EmptyPath(path)) { return 1; }
|
||||||
if (!cargo.Create(path, -1))
|
if (!cargo.Create(path, 0xAB))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,16 +101,16 @@
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);SODIUM_STATIC</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
<AdditionalIncludeDirectories>3rd\ftxui\include;3rd\libsodium\include;3rd\json\include;3rd\lz4\include;3rd\xxhash\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>3rd\libsodium\include;3rd\json\include;3rd\zstd\include;3rd\xxhash\include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>3rd\ftxui\Debug;3rd\lz4\lib;3rd\libsodium\lib\Debug</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>3rd\zstd\lib\Debug;3rd\xxhash\lib\Debug;3rd\libsodium\x64\Debug\v143\static</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>liblz4_static.lib;ftxui-component.lib;ftxui-dom.lib;ftxui-screen.lib;libsodium.lib</AdditionalDependencies>
|
<AdditionalDependencies>libsodium.lib;zstd_static.lib;xxhash.lib</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
|
@ -119,35 +119,32 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions);SODIUM_STATIC</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<AdditionalIncludeDirectories>3rd\ftxui\include;3rd\libsodium\include;3rd\json\include;3rd\lz4\include;</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>3rd\libsodium\include;3rd\json\include;3rd\zstd\include;3rd\xxhash\include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>3rd\libsodium\lib\Release;3rd\ftxui\Release;3rd\lz4\lib</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>3rd\zstd\lib\Release;3rd\libsodium\x64\Release\v143\static;3rd\xxhash\lib\Release</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>liblz4_static.lib;ftxui-component.lib;ftxui-dom.lib;ftxui-screen.lib;libsodium.lib</AdditionalDependencies>
|
<AdditionalDependencies>libsodium.lib;zstd_static.lib;xxhash.lib</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="CompressingManager.cpp" />
|
<ClCompile Include="CompressionManager.cpp" />
|
||||||
<ClCompile Include="CreateCargo.cpp" />
|
<ClCompile Include="CreateCargo.cpp" />
|
||||||
<ClCompile Include="EncryptionManager.cpp" />
|
<ClCompile Include="EncryptionManager.cpp" />
|
||||||
<ClCompile Include="ExtractCargo.cpp" />
|
<ClCompile Include="ExtractCargo.cpp" />
|
||||||
<ClCompile Include="Interface.cpp" />
|
|
||||||
<ClCompile Include="ViewCargo.cpp" />
|
<ClCompile Include="ViewCargo.cpp" />
|
||||||
<ClCompile Include="voidcmd.cpp" />
|
<ClCompile Include="voidcmd.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CompressingManager.h" />
|
<ClInclude Include="CompressionManager.h" />
|
||||||
<ClInclude Include="CreateCargo.h" />
|
<ClInclude Include="CreateCargo.h" />
|
||||||
<ClInclude Include="DataStruct.h" />
|
<ClInclude Include="DataStruct.h" />
|
||||||
<ClInclude Include="EncryptionManager.h" />
|
<ClInclude Include="EncryptionManager.h" />
|
||||||
<ClInclude Include="ExtractCargo.h" />
|
<ClInclude Include="ExtractCargo.h" />
|
||||||
<ClInclude Include="Interface.h" />
|
|
||||||
<ClInclude Include="Txtpp.h" />
|
|
||||||
<ClInclude Include="ViewCargo.h" />
|
<ClInclude Include="ViewCargo.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,12 @@
|
||||||
<ClCompile Include="ViewCargo.cpp">
|
<ClCompile Include="ViewCargo.cpp">
|
||||||
<Filter>Pliki źródłowe</Filter>
|
<Filter>Pliki źródłowe</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Interface.cpp">
|
|
||||||
<Filter>Pliki źródłowe</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="CompressingManager.cpp">
|
|
||||||
<Filter>Pliki źródłowe</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="EncryptionManager.cpp">
|
<ClCompile Include="EncryptionManager.cpp">
|
||||||
<Filter>Pliki źródłowe</Filter>
|
<Filter>Pliki źródłowe</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CompressionManager.cpp">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CreateCargo.h">
|
<ClInclude Include="CreateCargo.h">
|
||||||
|
|
@ -47,21 +44,15 @@
|
||||||
<ClInclude Include="ViewCargo.h">
|
<ClInclude Include="ViewCargo.h">
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Txtpp.h">
|
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="DataStruct.h">
|
<ClInclude Include="DataStruct.h">
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Interface.h">
|
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="CompressingManager.h">
|
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="EncryptionManager.h">
|
<ClInclude Include="EncryptionManager.h">
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CompressionManager.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="icon.ico">
|
<Image Include="icon.ico">
|
||||||
|
|
|
||||||
BIN
xxhash.dll
Normal file
BIN
xxhash.dll
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue