/*
* This file is part of VoidArchiveTool.
*
* Copyright (C) 2025 Yanczi
*
* Void Archive Toolis free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#pragma once
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "DataStruct.h"
#include "Txtpp.h"
#include "CompressingManager.h"
#include "EncryptionManager.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
struct MethodFlags
{
bool compressing = false;
bool encryption = false;
};
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;
MethodFlags methodFlags;
std::string catalogPath;
std::string tempFile;
std::string cargoFile;
std::vector filesList;
EncryptionManager crypt;
// listy wyjątków
std::vector ignoreList;
std::vector 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&);
// Przygotowanie nagłówków i plików
std::vector 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
uint8_t CheckFileOnTheList(const std::string&, std::vector&, std::vector&);
// 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&);
// Zamień cały ciąg na duże litery
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::vector&, std::vector&);
// Znajdź wskazany element na liście
bool FindOnTheList(const std::vector&, const std::string&);
};