Dodaj pliki projektów.
This commit is contained in:
parent
4912ed6774
commit
f6150b0d17
18 changed files with 9210 additions and 0 deletions
439
CreateCargo.cpp
Normal file
439
CreateCargo.cpp
Normal file
|
|
@ -0,0 +1,439 @@
|
||||||
|
/*
|
||||||
|
* 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 "CreateCargo.h"
|
||||||
|
|
||||||
|
CreateCargo::CreateCargo()
|
||||||
|
:compressingFlag(false)
|
||||||
|
, filteringFlag(false)
|
||||||
|
, signature(SIGNATURE)
|
||||||
|
, extension(EXTENSION)
|
||||||
|
, version(VERSION)
|
||||||
|
, offset(0)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateCargo::~CreateCargo() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Punk wejœcia do tworzenia archivum
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CreateCargo::Create(const std::string& path, bool compress, bool filters)
|
||||||
|
{
|
||||||
|
cargoFile = path + "." + extension;
|
||||||
|
catalogPath = path;
|
||||||
|
compressingFlag = compress;
|
||||||
|
filteringFlag = filters;
|
||||||
|
|
||||||
|
//Sprawdzanie pakowanego kontentu
|
||||||
|
if (!std::filesystem::is_directory(path))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The specified directory is a file!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!std::filesystem::exists(path))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The specified directory does not exist!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pobieranie listy plików wyj¹tków
|
||||||
|
if (filters)
|
||||||
|
{
|
||||||
|
std::string filterFile = path + ".txt";
|
||||||
|
if (!std::filesystem::exists(filterFile))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Missing " << filterFile << " file!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
cargo.open(cargoFile, std::ios::binary);
|
||||||
|
|
||||||
|
//Rozpocznij process zapisywania danych do kontenera
|
||||||
|
if (!WriteCargo())
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Failed to create container!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Tworzenie listy plików do spakowania
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CreateCargo::GetFileList(const std::string& path)
|
||||||
|
{
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator(path))
|
||||||
|
{
|
||||||
|
std::string tmpPath = entry.path().string();
|
||||||
|
if (std::filesystem::is_directory(tmpPath))
|
||||||
|
{
|
||||||
|
GetFileList(tmpPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CheckIgnorePath(tmpPath))
|
||||||
|
{
|
||||||
|
filesList.push_back(PathToUnixLike(tmpPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filesList.size() > 0 ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Konwersja œcie¿ki na unix like
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::string CreateCargo::PathToUnixLike(std::string path)
|
||||||
|
{
|
||||||
|
std::replace(path.begin(), path.end(), '\\', '/');
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Kasowanie wskazanego katalogu ze œcie¿ki
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::string CreateCargo::RemoveStartPath(const std::filesystem::path& path)
|
||||||
|
{
|
||||||
|
std::filesystem::path cleanPath;
|
||||||
|
|
||||||
|
auto it = path.begin();
|
||||||
|
if (it != path.end()) { ++it; }
|
||||||
|
|
||||||
|
for (; it != path.end(); ++it)
|
||||||
|
{
|
||||||
|
cleanPath /= *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleanPath.string();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Tworzenie nag³owka pliku
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CargoHead CreateCargo::CreateCargoHead(const uint32_t& filesLen, const uint64_t& table)
|
||||||
|
{
|
||||||
|
CargoHead ch;
|
||||||
|
|
||||||
|
ch.signature = signature;
|
||||||
|
ch.version = version;
|
||||||
|
ch.files = filesLen;
|
||||||
|
ch.table = table;
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Kompresowanie
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::vector<char> CreateCargo::Compressing(const std::vector<char>& raw)
|
||||||
|
{
|
||||||
|
int maxZipSize = LZ4_compressBound(raw.size());
|
||||||
|
std::vector<char> zip(maxZipSize);
|
||||||
|
int zipSize = LZ4_compress_default(raw.data(), zip.data(), raw.size(), maxZipSize);
|
||||||
|
zip.resize(zipSize);
|
||||||
|
|
||||||
|
return zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Sprawdza czy plik znajduje siê na liœcie
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CreateCargo::CheckFileOnTheList(const std::string& path, std::vector<char>& input, std::vector<char>& output)
|
||||||
|
{
|
||||||
|
//Flaga aktywna sprawdza czy plik jest na liœcie. Jeœli jest to zwraca surowedane
|
||||||
|
//Przeciwnie kompresuje dane
|
||||||
|
if (filteringFlag) {
|
||||||
|
if (FilteringData(path))
|
||||||
|
{
|
||||||
|
output = Compressing(input);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output = std::move(input);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Flaga aktywna kompresuje dane
|
||||||
|
if (compressingFlag)
|
||||||
|
{
|
||||||
|
output = Compressing(input);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
output = std::move(input);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Przygotowanie nag³ówków i plików
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::vector<FilesTable> CreateCargo::ComputingHeadFiles()
|
||||||
|
{
|
||||||
|
//Utwórz header TMP. Zabezpiecza Pierwsze bajty na w³aœciwy nag³ówek
|
||||||
|
CargoHead cargoHead = CreateCargoHead(0, 0);
|
||||||
|
offset += cargoHead.signature.length() + sizeof(cargoHead.version) + sizeof(cargoHead.files) + sizeof(cargoHead.table);
|
||||||
|
|
||||||
|
//Zapisanie TMP nag³owka do pliku
|
||||||
|
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));
|
||||||
|
|
||||||
|
std::vector<FilesTable> filesTable;
|
||||||
|
|
||||||
|
//Tworzenie nag³ówków plików
|
||||||
|
for (const auto& file : filesList)
|
||||||
|
{
|
||||||
|
std::string path = PathToUnixLike(RemoveStartPath(file));
|
||||||
|
std::ifstream f(file, std::ios::binary | std::ios::ate);
|
||||||
|
|
||||||
|
//Obliczanie rozmiaru pliku
|
||||||
|
size_t size = f.tellg();
|
||||||
|
f.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
|
//Wczytanie pliku do pamiêci
|
||||||
|
std::vector<char> buffor(size);
|
||||||
|
f.read(buffor.data(), size);
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
//Tworzenie hashu CRC
|
||||||
|
uint64_t crc = XXH64(buffor.data(), buffor.size(), VERSION);
|
||||||
|
|
||||||
|
//Kompresjia
|
||||||
|
std::vector<char> zip;
|
||||||
|
bool isZip = CheckFileOnTheList(path, buffor, zip);
|
||||||
|
|
||||||
|
FilesTable ft;
|
||||||
|
ft.nameFile = path;
|
||||||
|
ft.nameLen = path.length();
|
||||||
|
ft.offset = offset;
|
||||||
|
ft.size = zip.size();
|
||||||
|
ft.rawSize = size;
|
||||||
|
ft.isZip = isZip;
|
||||||
|
ft.crc = crc;
|
||||||
|
|
||||||
|
cargo.write(reinterpret_cast<const char*>(zip.data()), zip.size());
|
||||||
|
|
||||||
|
filesTable.push_back(ft);
|
||||||
|
offset += zip.size();
|
||||||
|
}
|
||||||
|
return filesTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Wczytanie filtrów wyj¹tków
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CreateCargo::GetFilters(const std::string& filterFile)
|
||||||
|
{
|
||||||
|
std::cout << "Downloading the exception list" << std::endl;
|
||||||
|
|
||||||
|
Txtpp ff(filterFile);
|
||||||
|
|
||||||
|
// Lista plików do skompresowania
|
||||||
|
zipList = ff.Get(KEY_ZIP);
|
||||||
|
|
||||||
|
// Lista plików do pominiêcia
|
||||||
|
ignoreList = ff.Get(KEY_IGNORE);
|
||||||
|
|
||||||
|
ff.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// ZnajdŸ wskazany element na liœcie
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CreateCargo::FindOnTheList(const std::vector<std::string>& list, const std::string& element)
|
||||||
|
{
|
||||||
|
auto it = std::find(list.begin(), list.end(), element);
|
||||||
|
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
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CreateCargo::CheckFileExtension(const std::filesystem::path& p, const std::vector<std::string>& patterns) {
|
||||||
|
std::string ext = UpperString(p.extension().string());
|
||||||
|
|
||||||
|
return FindOnTheList(patterns, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Zamieñ ca³y ci¹g na du¿e litery
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::string CreateCargo::UpperString(std::string s) {
|
||||||
|
std::transform(s.begin(), s.end(), s.begin(),
|
||||||
|
[](unsigned char c) { return static_cast<char>(std::toupper(c)); });
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// 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
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CreateCargo::WriteCargo()
|
||||||
|
{
|
||||||
|
std::cout << "Packing files..." << std::endl;
|
||||||
|
|
||||||
|
uint32_t filesLen = filesList.size();
|
||||||
|
|
||||||
|
//Przygotowanie nag³ówków plików i przetworzenie danych
|
||||||
|
std::vector<FilesTable> filesHead = ComputingHeadFiles();
|
||||||
|
|
||||||
|
//std::ofstream cargo(cargoFile, std::ios::binary);
|
||||||
|
|
||||||
|
if (!cargo.is_open())
|
||||||
|
{
|
||||||
|
std::cerr << "ERROR: Failed to create container " << cargoFile << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& head : filesHead)
|
||||||
|
{
|
||||||
|
// Œcie¿ka do plików
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&head.nameLen), sizeof(head.nameLen));
|
||||||
|
cargo.write(head.nameFile.data(), head.nameLen);
|
||||||
|
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&head.offset), sizeof(head.offset));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&head.size), sizeof(head.size));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&head.rawSize), sizeof(head.rawSize));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&head.crc), sizeof(head.crc));
|
||||||
|
cargo.write(reinterpret_cast<const char*>(&head.isZip), sizeof(head.isZip));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Cofnij siê na pocz¹tek pliku
|
||||||
|
cargo.seekp(std::ios::beg);
|
||||||
|
|
||||||
|
//Utwórz header
|
||||||
|
CargoHead cargoHead = CreateCargoHead(filesLen, offset);
|
||||||
|
|
||||||
|
//Nadpisz tymczasowy nag³ówek
|
||||||
|
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.close();
|
||||||
|
|
||||||
|
std::cout << "The container was successfully created! " << cargoFile << std::endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
131
CreateCargo.h
Normal file
131
CreateCargo.h
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* 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 <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
#include <fstream>
|
||||||
|
#include <lz4.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <utility>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "DataStruct.h"
|
||||||
|
#include "Txtpp.h"
|
||||||
|
#include "xxhash.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define COMPRESSION_LEVEL 12 // Poziom kompresji plików (3 < 12)
|
||||||
|
|
||||||
|
#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_CRYPT "CRYPT" // Plili które maj¹ byæ zaszyfrowane
|
||||||
|
|
||||||
|
#define ALL_FILE ".*" // Wszystkie pliki
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CreateCargo {
|
||||||
|
public:
|
||||||
|
CreateCargo();
|
||||||
|
virtual ~CreateCargo();
|
||||||
|
|
||||||
|
// Punk wejœcia do tworzenia archivum
|
||||||
|
bool Create(const std::string&, bool, bool);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool compressingFlag;
|
||||||
|
bool filteringFlag;
|
||||||
|
const std::string signature;
|
||||||
|
const std::string extension;
|
||||||
|
const uint8_t version;
|
||||||
|
|
||||||
|
|
||||||
|
std::string catalogPath;
|
||||||
|
std::string tempFile;
|
||||||
|
std::string cargoFile;
|
||||||
|
|
||||||
|
std::vector<std::string> filesList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// listy wyj¹tków
|
||||||
|
std::vector<std::string> ignoreList;
|
||||||
|
std::vector<std::string> zipList;
|
||||||
|
|
||||||
|
|
||||||
|
std::ofstream cargo;
|
||||||
|
uint64_t offset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Tworzenie listy plików do spakowania
|
||||||
|
bool GetFileList(const std::string&);
|
||||||
|
|
||||||
|
// Konwersja œcie¿ki na unix like
|
||||||
|
std::string PathToUnixLike(std::string);
|
||||||
|
|
||||||
|
// Kasowanie wskazanego katalogu ze œcie¿ki
|
||||||
|
std::string RemoveStartPath(const std::filesystem::path&);
|
||||||
|
|
||||||
|
// Trworzenie archiwum
|
||||||
|
bool WriteCargo();
|
||||||
|
|
||||||
|
// Tworzenie nag³owka pliku
|
||||||
|
CargoHead CreateCargoHead(const uint32_t&, const uint64_t&);
|
||||||
|
|
||||||
|
// Kompresowanie
|
||||||
|
std::vector<char> Compressing(const std::vector<char>&);
|
||||||
|
|
||||||
|
// Przygotowanie nag³ówków i plików
|
||||||
|
std::vector<FilesTable> ComputingHeadFiles();
|
||||||
|
|
||||||
|
// Sprawdzanie czy plik znajduje siê na liœcie
|
||||||
|
bool FilteringData(const std::string&);
|
||||||
|
|
||||||
|
// Wczytanie filtrów wyj¹tków
|
||||||
|
void GetFilters(const std::string&);
|
||||||
|
|
||||||
|
// Sprawdza czy plik znajduje siê na liœcie
|
||||||
|
bool 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
|
||||||
|
bool CheckFileExtension(const std::filesystem::path&, const std::vector<std::string>&);
|
||||||
|
|
||||||
|
// Zamieñ ca³y ci¹g na du¿e litery
|
||||||
|
std::string UpperString(std::string);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
bool FindOnTheList(const std::vector<std::string>&, const std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
59
DataStruct.h
Normal file
59
DataStruct.h
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* 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 <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define EXTENSION "pak"
|
||||||
|
#define SIGNATURE "VoidFS"
|
||||||
|
|
||||||
|
#define VERSION 11
|
||||||
|
|
||||||
|
|
||||||
|
//Prgoram title
|
||||||
|
#define PROGRAM_TITLE "Void Archive Tool"
|
||||||
|
#define PROGRAM_VERSION "v1.1"
|
||||||
|
#define PROGRAM_AUTHOR "Yanczi"
|
||||||
|
#define PROGRAM_COMPILING "1 September 2025"
|
||||||
|
#define PROGRAM_LICENSE "GNU LGPL v3"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct CargoHead
|
||||||
|
{
|
||||||
|
std::string signature;
|
||||||
|
uint8_t version;
|
||||||
|
uint32_t files;
|
||||||
|
uint64_t table;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FilesTable
|
||||||
|
{
|
||||||
|
uint8_t nameLen;
|
||||||
|
std::string nameFile;
|
||||||
|
uint64_t offset;
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t rawSize;
|
||||||
|
uint64_t crc;
|
||||||
|
bool isZip;
|
||||||
|
};
|
||||||
217
ExtractCargo.cpp
Normal file
217
ExtractCargo.cpp
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
* 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 "ExtractCargo.h"
|
||||||
|
|
||||||
|
ExtractCargo::ExtractCargo()
|
||||||
|
:filesLen(0)
|
||||||
|
, tablePosition(0)
|
||||||
|
, filesHeadsOffset(0)
|
||||||
|
, version(VERSION)
|
||||||
|
, signature(SIGNATURE)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractCargo::~ExtractCargo()
|
||||||
|
{
|
||||||
|
if (cargoFile.is_open())
|
||||||
|
{
|
||||||
|
cargoFile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Punkt wejœcia
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool ExtractCargo::Extract(const std::string& cFile)
|
||||||
|
{
|
||||||
|
cargoFileName = cFile;
|
||||||
|
|
||||||
|
//SprawdŸ czy plik istnieje
|
||||||
|
if (!std::filesystem::exists(cargoFileName))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The given file is not exist!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SprawdŸ czy plik jets plikiem
|
||||||
|
if (!std::filesystem::is_regular_file(cargoFileName))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The given file is a directory!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Otwieranie kontenera
|
||||||
|
cargoFile.open(cargoFileName, std::ios::binary);
|
||||||
|
|
||||||
|
if (!CheckCargoFile())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadFilesTable();
|
||||||
|
ExtractingFilesFromCargo();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Sprawdzenie poprawnoœci archiwum
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool ExtractCargo::CheckCargoFile()
|
||||||
|
{
|
||||||
|
std::vector<char> magic(6);
|
||||||
|
uint8_t cargoVer = 0;
|
||||||
|
|
||||||
|
if (!cargoFile.is_open())
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Failed to open container" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
if (std::string(magic.begin(), magic.end()) != signature)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cargoVer != version)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Wrong cargo version" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
filesHeadsOffset = signature.length() + sizeof(cargoVer) + sizeof(filesLen);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Dekomprezja danych
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
std::vector<char> ExtractCargo::DecompressingData(const std::vector<char>& zip, const uint32_t& estimatedSize)
|
||||||
|
{
|
||||||
|
std::vector<char> unzip(estimatedSize);
|
||||||
|
|
||||||
|
int sizeData = LZ4_decompress_safe(
|
||||||
|
zip.data(),
|
||||||
|
unzip.data(),
|
||||||
|
static_cast<int>(zip.size()),
|
||||||
|
static_cast<int>(estimatedSize)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (sizeData < 0)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("LZ4 Decompressing Error");
|
||||||
|
}
|
||||||
|
unzip.resize(sizeData);
|
||||||
|
|
||||||
|
return unzip;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Pobieranie nag³ówków plików
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void ExtractCargo::LoadFilesTable()
|
||||||
|
{
|
||||||
|
cargoFile.seekg(tablePosition);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < filesLen; ++i)
|
||||||
|
{
|
||||||
|
FilesTable fhTmp;
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&fhTmp.nameLen), sizeof(fhTmp.nameLen));
|
||||||
|
|
||||||
|
std::vector<char> nameBuffor(fhTmp.nameLen);
|
||||||
|
cargoFile.read(nameBuffor.data(), fhTmp.nameLen);
|
||||||
|
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
||||||
|
|
||||||
|
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.rawSize), sizeof(fhTmp.rawSize));
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&fhTmp.crc), sizeof(fhTmp.crc));
|
||||||
|
cargoFile.read(reinterpret_cast<char*>(&fhTmp.isZip), sizeof(fhTmp.isZip));
|
||||||
|
|
||||||
|
filesHeads.push_back(fhTmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Wypakowywanie plików
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void ExtractCargo::ExtractingFilesFromCargo()
|
||||||
|
{
|
||||||
|
for (const auto& fh : filesHeads)
|
||||||
|
{
|
||||||
|
std::filesystem::path dir = cargoFileName.stem() / fh.nameFile;
|
||||||
|
CreateDirections(dir);
|
||||||
|
std::ofstream file(dir, std::ios::binary);
|
||||||
|
|
||||||
|
cargoFile.seekg(fh.offset);
|
||||||
|
std::vector<char> buffor(fh.size);
|
||||||
|
|
||||||
|
cargoFile.read(buffor.data(), fh.size);
|
||||||
|
|
||||||
|
std::vector<char> rawBuffor = fh.isZip ? DecompressingData(buffor, fh.rawSize) : buffor;
|
||||||
|
|
||||||
|
if (!HashValid(rawBuffor, fh.crc))
|
||||||
|
{
|
||||||
|
std::cerr << fh.nameFile << " Error: Corrupted data integration CRC" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.write(reinterpret_cast<const char*>(rawBuffor.data()), rawBuffor.size());
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Unpacking complete!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Utwórz katalog
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void ExtractCargo::CreateDirections(std::filesystem::path path)
|
||||||
|
{
|
||||||
|
if (!std::filesystem::exists(path.parent_path()))
|
||||||
|
{
|
||||||
|
std::filesystem::create_directories(path.parent_path());
|
||||||
|
}
|
||||||
|
}
|
||||||
77
ExtractCargo.h
Normal file
77
ExtractCargo.h
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* 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 <vector>
|
||||||
|
#include <fstream>
|
||||||
|
#include <lz4.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "DataStruct.h"
|
||||||
|
#include "xxhash.h"
|
||||||
|
|
||||||
|
class ExtractCargo {
|
||||||
|
public:
|
||||||
|
ExtractCargo();
|
||||||
|
virtual ~ExtractCargo();
|
||||||
|
|
||||||
|
// Punkt wejœcia
|
||||||
|
bool Extract(const std::string&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::filesystem::path cargoFileName;
|
||||||
|
|
||||||
|
uint32_t filesLen;
|
||||||
|
uint64_t tablePosition;
|
||||||
|
uint8_t filesHeadsOffset;
|
||||||
|
|
||||||
|
const uint8_t version;
|
||||||
|
const std::string signature;
|
||||||
|
|
||||||
|
std::vector<FilesTable> filesHeads;
|
||||||
|
|
||||||
|
|
||||||
|
std::ifstream cargoFile;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sprawdzenie poprawnoœci archiwum
|
||||||
|
bool CheckCargoFile();
|
||||||
|
|
||||||
|
// Wypakowywanie plików
|
||||||
|
void ExtractingFilesFromCargo();
|
||||||
|
|
||||||
|
// Pobieranie nag³ówków plików
|
||||||
|
void LoadFilesTable();
|
||||||
|
|
||||||
|
// Dekomprezja danych
|
||||||
|
std::vector<char> DecompressingData(const std::vector<char>&, const uint32_t&);
|
||||||
|
|
||||||
|
// Sprawdzanie sumy kontrolnej
|
||||||
|
bool HashValid(const std::vector<char>&, const uint64_t&);
|
||||||
|
|
||||||
|
// Utwórz katalog
|
||||||
|
void CreateDirections(std::filesystem::path);
|
||||||
|
|
||||||
|
};
|
||||||
18
Interface.cpp
Normal file
18
Interface.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#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
Normal file
14
Interface.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#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&);
|
||||||
|
};
|
||||||
|
|
||||||
148
Txtpp.h
Normal file
148
Txtpp.h
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
198
ViewCargo.cpp
Normal file
198
ViewCargo.cpp
Normal file
|
|
@ -0,0 +1,198 @@
|
||||||
|
/*
|
||||||
|
* 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 "ViewCargo.h"
|
||||||
|
|
||||||
|
ViewCargo::ViewCargo()
|
||||||
|
:signature(SIGNATURE)
|
||||||
|
, version(VERSION)
|
||||||
|
, filesLen(0)
|
||||||
|
, tablePos(0)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Wywo³ywanie
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool ViewCargo::View(const std::string& path)
|
||||||
|
{
|
||||||
|
//SprawdŸ czy plik istnieje
|
||||||
|
if (!std::filesystem::exists(path))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The given file is not exist!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SprawdŸ czy plik jets plikiem
|
||||||
|
if (!std::filesystem::is_regular_file(path))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: The given file is a directory!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SprawdŸ czy kontener jest prawid³owy
|
||||||
|
if (!CheckCargoFile(path))
|
||||||
|
{
|
||||||
|
std::cerr << "Nie prawidlowa struktura kontenera Void" << std::endl;
|
||||||
|
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("CRC") | 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Sprawdzenie poprawnoœci kontenera
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool ViewCargo::CheckCargoFile(const std::string& path)
|
||||||
|
{
|
||||||
|
std::vector<char> magic(signature.length());
|
||||||
|
uint8_t cargoVer = 0;
|
||||||
|
|
||||||
|
std::ifstream cargo(path, std::ios::binary);
|
||||||
|
|
||||||
|
if (!cargo.is_open())
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Failed to open container" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Odczytywanie pierwszych 11 bajtów nag³ówka pliku
|
||||||
|
// 6 pierwszych to sygnatura
|
||||||
|
// 1 wersja kontenera
|
||||||
|
// 4 iloœæ plików w kontenerze
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
cargo.read(magic.data(), magic.size());
|
||||||
|
cargo.read(reinterpret_cast<char*>(&cargoVer), sizeof(cargoVer));
|
||||||
|
cargo.read(reinterpret_cast<char*>(&filesLen), sizeof(filesLen));
|
||||||
|
cargo.read(reinterpret_cast<char*>(&tablePos), sizeof(tablePos));
|
||||||
|
|
||||||
|
//SprawdŸ czy kontener ma poprawn¹ sygnature
|
||||||
|
if (std::string(magic.begin(), magic.end()) != signature)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||||
|
cargo.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SprawdŸ spójnoœæ wersji kontenera
|
||||||
|
if (cargoVer != version)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Wrong cargo version" << std::endl;
|
||||||
|
cargo.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cargo.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// 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;
|
||||||
|
cargo.read(reinterpret_cast<char*>(&fhTmp.nameLen), sizeof(fhTmp.nameLen));
|
||||||
|
|
||||||
|
std::vector<char> nameBuffor(fhTmp.nameLen);
|
||||||
|
cargo.read(nameBuffor.data(), fhTmp.nameLen);
|
||||||
|
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
||||||
|
|
||||||
|
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.rawSize), sizeof(fhTmp.rawSize));
|
||||||
|
cargo.read(reinterpret_cast<char*>(&fhTmp.crc), sizeof(fhTmp.crc));
|
||||||
|
cargo.read(reinterpret_cast<char*>(&fhTmp.isZip), sizeof(fhTmp.isZip));
|
||||||
|
|
||||||
|
//Tworzenie wierszy tabeli
|
||||||
|
CreateTableRow(fhTmp.nameFile, fhTmp.isZip, fhTmp.crc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cargo.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Generowanie wierszy do tabeli
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void ViewCargo::CreateTableRow(std::string file, bool zip, uint64_t hash)
|
||||||
|
{
|
||||||
|
//Zamiania crc liczbowej na hex string
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "0x" << std::hex << std::uppercase << hash;
|
||||||
|
|
||||||
|
std::vector<ftxui::Element> cell;
|
||||||
|
|
||||||
|
ftxui::Element eZip;
|
||||||
|
|
||||||
|
//Dodawanie check boxa czy plik jest spakowany czy nie
|
||||||
|
if (zip)
|
||||||
|
{
|
||||||
|
eZip = ftxui::text(" [x] ") | ftxui::color(ftxui::Color::Green);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eZip = ftxui::text(" [ ] ") | ftxui::color(ftxui::Color::Red);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Dodawanie komurek
|
||||||
|
cell.push_back(eZip);
|
||||||
|
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();
|
||||||
|
}
|
||||||
54
ViewCargo.h
Normal file
54
ViewCargo.h
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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 <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <ftxui/dom/elements.hpp>
|
||||||
|
#include <ftxui/screen/screen.hpp>
|
||||||
|
|
||||||
|
#include "DataStruct.h"
|
||||||
|
|
||||||
|
class ViewCargo {
|
||||||
|
public:
|
||||||
|
ViewCargo();
|
||||||
|
virtual ~ViewCargo() = default;
|
||||||
|
|
||||||
|
bool View(const std::string&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string signature;
|
||||||
|
const uint8_t version;
|
||||||
|
|
||||||
|
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(std::string, bool, uint64_t);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
BIN
icon.ico
Normal file
BIN
icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 168 KiB |
1
resources.rc
Normal file
1
resources.rc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
IDI_MAIN_ICON ICON "icon.ico"
|
||||||
153
voidcmd.cpp
Normal file
153
voidcmd.cpp
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// Name : Void Archive Tool
|
||||||
|
// Author : Yanczi
|
||||||
|
// Version : 1.1
|
||||||
|
// Copyright : Yanczi 19-06-2025
|
||||||
|
// Description : Void Archive Tool. Packing and extract files
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <ftxui/dom/elements.hpp>
|
||||||
|
#include <ftxui/screen/screen.hpp>
|
||||||
|
|
||||||
|
#include "CreateCargo.h"
|
||||||
|
#include "ExtractCargo.h"
|
||||||
|
#include "ViewCargo.h"
|
||||||
|
#include "Interface.h"
|
||||||
|
|
||||||
|
void RenderHelp()
|
||||||
|
{
|
||||||
|
const std::string HelpTitle = "< Manual >";
|
||||||
|
const std::string HelpInstruction =
|
||||||
|
"voidarchive <parametr> <plik & katalog> \n"
|
||||||
|
" \n"
|
||||||
|
"COMPRESSION -c Pack and compress files from the specified directory \n"
|
||||||
|
"PACKING -p Pack files from the specified directory \n"
|
||||||
|
"FILTERING -f Pack the files according to the guidelines given in the <directory>.txt\n"
|
||||||
|
"EXTRACTING -x Extract files from the specified container \n"
|
||||||
|
"LISTING -ls List files stored in a container \n"
|
||||||
|
" \n"
|
||||||
|
" \n"
|
||||||
|
"<catalog>.txt \n"
|
||||||
|
" \n"
|
||||||
|
"Keys: \n"
|
||||||
|
" \n"
|
||||||
|
" {compress} - Compressing files -> /path/data/file.txt *.txt *.* - All files \n"
|
||||||
|
" {ignore} - Ignoring concrete files -> /path/data/file.txt *.txt \n";
|
||||||
|
|
||||||
|
Interface tui;
|
||||||
|
tui.TextBorder(HelpTitle, HelpInstruction);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmptyPath(std::string path)
|
||||||
|
{
|
||||||
|
if (path == "")
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Nie podano sciezki!" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
std::string path = "";
|
||||||
|
|
||||||
|
std::cout << "\n" << PROGRAM_TITLE << " " << PROGRAM_VERSION << " Release " << PROGRAM_COMPILING << std::endl;
|
||||||
|
std::cout << "Author: " << PROGRAM_AUTHOR << std::endl;
|
||||||
|
std::cout << "License: " << PROGRAM_LICENSE << "\n" << std::endl;
|
||||||
|
|
||||||
|
CreateCargo cargo;
|
||||||
|
ExtractCargo extract;
|
||||||
|
ViewCargo viewCargo;
|
||||||
|
|
||||||
|
for (int i = 0; i < argc; ++i)
|
||||||
|
{
|
||||||
|
std::string arg = argv[i];
|
||||||
|
|
||||||
|
if (arg == "-c" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
|
||||||
|
if (!EmptyPath(path)) { return 1; }
|
||||||
|
|
||||||
|
if (!cargo.Create(path, true, false))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-p" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
if (!cargo.Create(path, false, false))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-f" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
if (!EmptyPath(path)) { return 1; }
|
||||||
|
if (!cargo.Create(path, false, true))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-x" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
if (!EmptyPath(path)) { return 1; }
|
||||||
|
if (!extract.Extract(path))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-ls" && i + 1 < argc)
|
||||||
|
{
|
||||||
|
path = argv[i + 1];
|
||||||
|
if (!EmptyPath(path)) { return 1; }
|
||||||
|
if (!viewCargo.View(path))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "-help")
|
||||||
|
{
|
||||||
|
//std::cout << helpText << std::endl;
|
||||||
|
RenderHelp();
|
||||||
|
return 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
31
voidcmd.sln
Normal file
31
voidcmd.sln
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.14.36511.14 d17.14
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "voidcmd", "voidcmd.vcxproj", "{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{FC5A6D25-B824-4F4F-86C6-C2CC11D4F02B}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {DF4181CC-A7CE-4D70-B0CA-FCAB4DD07096}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
153
voidcmd.vcxproj
Normal file
153
voidcmd.vcxproj
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>17.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{fc5a6d25-b824-4f4f-86c6-c2cc11d4f02b}</ProjectGuid>
|
||||||
|
<RootNamespace>voidcmd</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="CreateCargo.cpp" />
|
||||||
|
<ClCompile Include="ExtractCargo.cpp" />
|
||||||
|
<ClCompile Include="Interface.cpp" />
|
||||||
|
<ClCompile Include="ViewCargo.cpp" />
|
||||||
|
<ClCompile Include="voidcmd.cpp" />
|
||||||
|
<ClCompile Include="xxhash.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="CreateCargo.h" />
|
||||||
|
<ClInclude Include="DataStruct.h" />
|
||||||
|
<ClInclude Include="ExtractCargo.h" />
|
||||||
|
<ClInclude Include="Interface.h" />
|
||||||
|
<ClInclude Include="Txtpp.h" />
|
||||||
|
<ClInclude Include="ViewCargo.h" />
|
||||||
|
<ClInclude Include="xxhash.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="icon.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="resources.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
70
voidcmd.vcxproj.filters
Normal file
70
voidcmd.vcxproj.filters
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Pliki źródłowe">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Pliki nagłówkowe">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Pliki zasobów">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="voidcmd.cpp">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="CreateCargo.cpp">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ExtractCargo.cpp">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ViewCargo.cpp">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="xxhash.c">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Interface.cpp">
|
||||||
|
<Filter>Pliki źródłowe</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="CreateCargo.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ExtractCargo.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ViewCargo.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Txtpp.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DataStruct.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="xxhash.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Interface.h">
|
||||||
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="icon.ico">
|
||||||
|
<Filter>Pliki zasobów</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="resources.rc">
|
||||||
|
<Filter>Pliki zasobów</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
42
xxhash.c
Normal file
42
xxhash.c
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* xxHash - Extremely Fast Hash algorithm
|
||||||
|
* Copyright (C) 2012-2023 Yann Collet
|
||||||
|
*
|
||||||
|
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* OWNER 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.
|
||||||
|
*
|
||||||
|
* You can contact the author at:
|
||||||
|
* - xxHash homepage: https://www.xxhash.com
|
||||||
|
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xxhash.c instantiates functions defined in xxhash.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define XXH_STATIC_LINKING_ONLY /* access advanced declarations */
|
||||||
|
#define XXH_IMPLEMENTATION /* access definitions */
|
||||||
|
|
||||||
|
#include "xxhash.h"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue