Podmiana zmiennych int8 na int16, Działa filtrowanie plików po przez podanie ścierzek

This commit is contained in:
yanczi 2025-11-11 13:46:56 +01:00
parent 293c1412ad
commit 621b4b6eb7
12 changed files with 66 additions and 81 deletions

View file

@ -37,12 +37,14 @@ CreateCargo::~CreateCargo() {
//-----------------------------------------------------------------------------
// Punk wejścia do tworzenia archivum
//-----------------------------------------------------------------------------
bool CreateCargo::Create(const std::string& path, int8_t flag)
bool CreateCargo::Create(const std::string& path, const int16_t& flag)
{
cargoFile = path + "." + extension;
catalogPath = path;
methodFlags = flag;
std::cout << "#1 FLAG: " << flag << " - " << methodFlags << std::endl;
//Sprawdzanie pakowanego kontentu
if (!std::filesystem::is_directory(path))
{
@ -56,14 +58,6 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
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
if (flag == -1)
{
@ -75,9 +69,13 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
}
GetFilters(filterFile);
}
else
//Pobieranie listy plików do spakowania
std::cout << "Creating a file list..." << std::endl;
if (!GetFileList(path))
{
// Dodaj tu coœ mordo
std::cerr << "Error: The specified directory contains no files!" << std::endl;
return false;
}
// Utworzenie kontenera
@ -104,6 +102,11 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
//-----------------------------------------------------------------------------
bool CreateCargo::GetFileList(const std::string& path)
{
for (const auto& el : encList)
{
std::cout << el << std::endl;
}
for (const auto& entry : std::filesystem::directory_iterator(path))
{
std::string tmpPath = entry.path().string();
@ -113,12 +116,35 @@ bool CreateCargo::GetFileList(const std::string& path)
}
else
{
std::string fileRef = RemoveStartPath(PathToUnixLike(tmpPath));
if (CheckIgnorePath(tmpPath))
{
std::cout << "FLAG: " << methodFlags << std::endl;
PathConf pc;
pc.path = PathToUnixLike(tmpPath);
pc.parameter = methodFlags;
filesPaths.push_back(pc);
if (methodFlags > -1)
{
std::cout << "NO FLAG" << std::endl;
pc.path = PathToUnixLike(tmpPath);
pc.parameter = methodFlags;
filesPaths.push_back(pc);
}
else
{
if (!FindOnTheList(ignoreList, fileRef))
{
if (FindOnTheList(zipList, fileRef))
{
pc.parameter = FindOnTheList(encList, fileRef) ? 3 : 1;
}
else
{
pc.parameter = FindOnTheList(encList, fileRef) ? 2 : 0;
}
pc.path = PathToUnixLike(tmpPath);
std::cout << pc.parameter << std::endl;
filesPaths.push_back(pc);
}
}
}
}
}
@ -171,7 +197,7 @@ CargoHead CreateCargo::CreateCargoHead(const uint32_t& filesLen, const uint64_t&
//-----------------------------------------------------------------------------
// Sprawdza czy plik znajduje się na liście
//-----------------------------------------------------------------------------
void CreateCargo::computingBytes(const int8_t& flag, std::vector<char>& input, std::vector<char>& output)
void CreateCargo::computingBytes(const int16_t& flag, 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
@ -266,43 +292,15 @@ void CreateCargo::GetFilters(const std::string& filterFile)
file.close();
// Lista plików do skompresowania
std::vector<std::string> zip = jslist[KEY_ZIP].get<std::vector<std::string>>();
zipList = jslist[KEY_ZIP].get<std::vector<std::string>>();
// Lista plików do zaszyfrowania
std::vector<std::string> enc = jslist[KEY_ENCRYPT].get<std::vector<std::string>>();
encList = jslist[KEY_ENCRYPT].get<std::vector<std::string>>();
// Lista plików do pominięcia
std::vector<std::string> ignore = jslist[KEY_IGNORE].get<std::vector<std::string>>();
PrepareList(zip, enc, ignore);
ignoreList = jslist[KEY_IGNORE].get<std::vector<std::string>>();
}
//-----------------------------------------------------------------------------
// 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))
{
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);
}
}
}
//-----------------------------------------------------------------------------
// Znajdź wskazany element na liście
//-----------------------------------------------------------------------------