Dodaj pliki projektów.
This commit is contained in:
parent
4912ed6774
commit
f6150b0d17
18 changed files with 9210 additions and 0 deletions
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&);
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue