Podmiana zmiennych int8 na int16, Działa filtrowanie plików po przez podanie ścierzek
This commit is contained in:
parent
293c1412ad
commit
621b4b6eb7
12 changed files with 66 additions and 81 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -372,3 +372,12 @@ test.*
|
||||||
pest2.*
|
pest2.*
|
||||||
*.hh
|
*.hh
|
||||||
*.key
|
*.key
|
||||||
|
test3/
|
||||||
|
test4/
|
||||||
|
test5/
|
||||||
|
test6/
|
||||||
|
test7/
|
||||||
|
test8/
|
||||||
|
test9/
|
||||||
|
test10/
|
||||||
|
testx/
|
||||||
|
|
@ -60,7 +60,7 @@ std::vector<char> CompressingManager::compress(const std::vector<char>& raw)
|
||||||
std::vector<char> zip;
|
std::vector<char> zip;
|
||||||
// Wstaw liczbê o iloœci bloków do vectora;
|
// Wstaw liczbê o iloœci bloków do vectora;
|
||||||
// Przekonpwertuj usigned int32 na ci¹g znkaów
|
// Przekonpwertuj usigned int32 na ci¹g znkaów
|
||||||
//uint16_t blockLen = blockSizes .size();
|
// uint16_t blockLen = blockSizes .size();
|
||||||
addIntToVector<uint16_t>(zip, blockLen);
|
addIntToVector<uint16_t>(zip, blockLen);
|
||||||
addIntToVector<uint32_t>(zip, maxBlockSize);
|
addIntToVector<uint32_t>(zip, maxBlockSize);
|
||||||
addIntToVector<uint32_t>(zip, lastChunkRawSize);
|
addIntToVector<uint32_t>(zip, lastChunkRawSize);
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,14 @@ CreateCargo::~CreateCargo() {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Punk wejścia do tworzenia archivum
|
// 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;
|
cargoFile = path + "." + extension;
|
||||||
catalogPath = path;
|
catalogPath = path;
|
||||||
methodFlags = flag;
|
methodFlags = flag;
|
||||||
|
|
||||||
|
std::cout << "#1 FLAG: " << flag << " - " << methodFlags << std::endl;
|
||||||
|
|
||||||
//Sprawdzanie pakowanego kontentu
|
//Sprawdzanie pakowanego kontentu
|
||||||
if (!std::filesystem::is_directory(path))
|
if (!std::filesystem::is_directory(path))
|
||||||
{
|
{
|
||||||
|
|
@ -56,14 +58,6 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
|
||||||
return false;
|
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
|
// Pobieranie listy plików wyjątków
|
||||||
if (flag == -1)
|
if (flag == -1)
|
||||||
{
|
{
|
||||||
|
|
@ -75,9 +69,13 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
|
||||||
}
|
}
|
||||||
GetFilters(filterFile);
|
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
|
// Utworzenie kontenera
|
||||||
|
|
@ -104,6 +102,11 @@ bool CreateCargo::Create(const std::string& path, int8_t flag)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CreateCargo::GetFileList(const std::string& path)
|
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))
|
for (const auto& entry : std::filesystem::directory_iterator(path))
|
||||||
{
|
{
|
||||||
std::string tmpPath = entry.path().string();
|
std::string tmpPath = entry.path().string();
|
||||||
|
|
@ -113,13 +116,36 @@ bool CreateCargo::GetFileList(const std::string& path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
std::string fileRef = RemoveStartPath(PathToUnixLike(tmpPath));
|
||||||
if (CheckIgnorePath(tmpPath))
|
if (CheckIgnorePath(tmpPath))
|
||||||
{
|
{
|
||||||
|
std::cout << "FLAG: " << methodFlags << std::endl;
|
||||||
PathConf pc;
|
PathConf pc;
|
||||||
|
if (methodFlags > -1)
|
||||||
|
{
|
||||||
|
std::cout << "NO FLAG" << std::endl;
|
||||||
pc.path = PathToUnixLike(tmpPath);
|
pc.path = PathToUnixLike(tmpPath);
|
||||||
pc.parameter = methodFlags;
|
pc.parameter = methodFlags;
|
||||||
filesPaths.push_back(pc);
|
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
|
// 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
|
//Flaga aktywna sprawdza czy plik jest na liście. Jeśli jest to zwraca surowedane
|
||||||
//Przeciwnie kompresuje dane
|
//Przeciwnie kompresuje dane
|
||||||
|
|
@ -266,43 +292,15 @@ void CreateCargo::GetFilters(const std::string& filterFile)
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// Lista plików do skompresowania
|
// 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
|
// 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
|
// Lista plików do pominięcia
|
||||||
std::vector<std::string> ignore = jslist[KEY_IGNORE].get<std::vector<std::string>>();
|
ignoreList = jslist[KEY_IGNORE].get<std::vector<std::string>>();
|
||||||
|
|
||||||
PrepareList(zip, enc, ignore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// 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
|
// Znajdź wskazany element na liście
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -38,21 +38,17 @@
|
||||||
#include "EncryptionManager.h"
|
#include "EncryptionManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define KEY_ZIP "compress" // Pliki do skompresowania
|
||||||
|
#define KEY_RAW "raw" // Pliki które maj¹ pozostaæ w oryginalnej formie
|
||||||
#define COMPRESSION_LEVEL 12 // Poziom kompresji plików (3 < 12)
|
#define KEY_IGNORE "ignore" // Pliki pominiête przy pakowaniu
|
||||||
|
#define KEY_ENCRYPT "encrypt" // Plili które maj¹ byæ zaszyfrowane
|
||||||
#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
|
#define ALL_FILE ".*" // Wszystkie pliki
|
||||||
|
|
||||||
struct PathConf
|
struct PathConf
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
int8_t parameter;
|
int16_t parameter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CreateCargo {
|
class CreateCargo {
|
||||||
|
|
@ -61,14 +57,14 @@ public:
|
||||||
virtual ~CreateCargo();
|
virtual ~CreateCargo();
|
||||||
|
|
||||||
// Punk wejœcia do tworzenia archivum
|
// Punk wejœcia do tworzenia archivum
|
||||||
bool Create(const std::string&, int8_t);
|
bool Create(const std::string&, const int16_t&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string signature;
|
const std::string signature;
|
||||||
const std::string extension;
|
const std::string extension;
|
||||||
const short version;
|
const short version;
|
||||||
|
|
||||||
int8_t methodFlags;
|
short methodFlags;
|
||||||
|
|
||||||
|
|
||||||
std::string catalogPath;
|
std::string catalogPath;
|
||||||
|
|
@ -82,6 +78,7 @@ private:
|
||||||
// listy wyj¹tków
|
// listy wyj¹tków
|
||||||
std::vector<std::string> ignoreList;
|
std::vector<std::string> ignoreList;
|
||||||
std::vector<std::string> zipList;
|
std::vector<std::string> zipList;
|
||||||
|
std::vector<std::string> encList;
|
||||||
|
|
||||||
// G³ówna lista plików z parametrami
|
// G³ówna lista plików z parametrami
|
||||||
std::vector<PathConf> filesPaths;
|
std::vector<PathConf> filesPaths;
|
||||||
|
|
@ -117,7 +114,7 @@ private:
|
||||||
void GetFilters(const std::string&);
|
void GetFilters(const std::string&);
|
||||||
|
|
||||||
// Sprawdza czy plik znajduje siê na liœcie
|
// Sprawdza czy plik znajduje siê na liœcie
|
||||||
void computingBytes(const int8_t&, std::vector<char>&, std::vector<char>&);
|
void computingBytes(const int16_t&, std::vector<char>&, std::vector<char>&);
|
||||||
|
|
||||||
// Kasowanie z listy plików ignorow
|
// Kasowanie z listy plików ignorow
|
||||||
bool CheckIgnorePath(const std::string&);
|
bool CheckIgnorePath(const std::string&);
|
||||||
|
|
@ -136,8 +133,5 @@ private:
|
||||||
|
|
||||||
// ZnajdŸ wskazany element na liœcie
|
// ZnajdŸ wskazany element na liœcie
|
||||||
bool FindOnTheList(const std::vector<std::string>&, const std::string&);
|
bool FindOnTheList(const std::vector<std::string>&, const std::string&);
|
||||||
|
|
||||||
// Przygotuj listê plików do spakowania
|
|
||||||
void PrepareList(const std::vector<std::string>&, const std::vector<std::string>&, const std::vector<std::string>&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
#include "CreateCargoEX.h"
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#pragma once
|
|
||||||
class CreateCargoEX
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CreateCargoEX();
|
|
||||||
~CreateCargoEX() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -66,11 +66,11 @@ struct CargoHead
|
||||||
|
|
||||||
struct FilesTable
|
struct FilesTable
|
||||||
{
|
{
|
||||||
uint8_t nameLen;
|
int16_t nameLen;
|
||||||
std::string nameFile;
|
std::string nameFile;
|
||||||
uint64_t hashName;
|
uint64_t hashName;
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint64_t crc;
|
uint64_t crc;
|
||||||
int8_t flag;
|
int16_t flag;
|
||||||
};
|
};
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
test3/plik3.bin
BIN
test3/plik3.bin
Binary file not shown.
|
|
@ -134,7 +134,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="CompressingManager.cpp" />
|
<ClCompile Include="CompressingManager.cpp" />
|
||||||
<ClCompile Include="CreateCargo.cpp" />
|
<ClCompile Include="CreateCargo.cpp" />
|
||||||
<ClCompile Include="CreateCargoEX.cpp" />
|
|
||||||
<ClCompile Include="EncryptionManager.cpp" />
|
<ClCompile Include="EncryptionManager.cpp" />
|
||||||
<ClCompile Include="ExtractCargo.cpp" />
|
<ClCompile Include="ExtractCargo.cpp" />
|
||||||
<ClCompile Include="Interface.cpp" />
|
<ClCompile Include="Interface.cpp" />
|
||||||
|
|
@ -144,7 +143,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CompressingManager.h" />
|
<ClInclude Include="CompressingManager.h" />
|
||||||
<ClInclude Include="CreateCargo.h" />
|
<ClInclude Include="CreateCargo.h" />
|
||||||
<ClInclude Include="CreateCargoEX.h" />
|
|
||||||
<ClInclude Include="DataStruct.h" />
|
<ClInclude Include="DataStruct.h" />
|
||||||
<ClInclude Include="EncryptionManager.h" />
|
<ClInclude Include="EncryptionManager.h" />
|
||||||
<ClInclude Include="ExtractCargo.h" />
|
<ClInclude Include="ExtractCargo.h" />
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,6 @@
|
||||||
<ClInclude Include="ViewCargo.h">
|
<ClInclude Include="ViewCargo.h">
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Txtpp.h">
|
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="DataStruct.h">
|
<ClInclude Include="DataStruct.h">
|
||||||
<Filter>Pliki nagłówkowe</Filter>
|
<Filter>Pliki nagłówkowe</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue