/* * 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 "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 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 = ".*"; inline constexpr std::string_view hpp = "keyhpp"; } struct PathConf { std::string path; uint8_t parameter; }; class CreateCargo { public: CreateCargo(); virtual ~CreateCargo(); // Punk wejścia do tworzenia archivum bool Create(const std::string&, const uint8_t&); private: const std::string signature; const std::string extension; const signed char version; uint8_t methodFlags; XXH64_state_t* xxhState; std::string catalogPath; std::string tempFile; std::string cargoFile; std::vector filesList; EncryptionManager eman; CompressionManager cman; bool hppKey; // listy wyjątków std::vector ignoreList; std::vector zipList; std::vector encList; // Główna lista plików z parametrami std::vector filesPaths; 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(); // Wczytanie filtrów wyjątków void GetFilters(const std::string&); // Sprawdzanie rozszeżeń plików bool CheckFileExtension(const std::string&, const std::vector&); // Zamień cały ciąg na duże litery std::string UpperString(std::string); // Znajdź wskazany element na liście bool FindOnTheList(const std::vector&, const std::string&); };