Podmiana LZ4 na ZSTD raw block. Podmiana CompressManager na ChunkManager
This commit is contained in:
parent
00d4b00209
commit
b3c317c914
10 changed files with 244 additions and 267 deletions
128
CreateCargo.cpp
128
CreateCargo.cpp
|
|
@ -110,31 +110,28 @@ bool CreateCargo::GetFileList(const std::string& path)
|
|||
else
|
||||
{
|
||||
std::string fileRef = RemoveStartPath(PathToUnixLike(tmpPath));
|
||||
if (CheckIgnorePath(tmpPath))
|
||||
PathConf pc;
|
||||
if (methodFlags > -1)
|
||||
{
|
||||
PathConf pc;
|
||||
if (methodFlags > -1)
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
pc.parameter = methodFlags;
|
||||
filesPaths.push_back(pc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!FindOnTheList(ignoreList, fileRef) || !CheckFileExtension(fileRef, ignoreList))
|
||||
{
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
pc.parameter = methodFlags;
|
||||
filesPaths.push_back(pc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!FindOnTheList(ignoreList, fileRef) || !CheckFileExtension(fileRef, ignoreList))
|
||||
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
|
||||
{
|
||||
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 3 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 2 : 0;
|
||||
}
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
std::cout << pc.path << " - " << pc.parameter << std::endl;
|
||||
filesPaths.push_back(pc);
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 3 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 2 : 0;
|
||||
}
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
std::cout << pc.path << " - " << pc.parameter << std::endl;
|
||||
filesPaths.push_back(pc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,12 +189,12 @@ void CreateCargo::computingBytes(const int16_t& flag, std::vector<char>& input,
|
|||
{
|
||||
//Flaga aktywna sprawdza czy plik jest na liście. Jeśli jest to zwraca surowedane
|
||||
//Przeciwnie kompresuje dane
|
||||
CompressingManager cm;
|
||||
ChunkManager cm(crypt);
|
||||
|
||||
switch (flag)
|
||||
{
|
||||
case 1:
|
||||
output = cm.compress(input);
|
||||
output = cm.chunked(input, false);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
|
@ -205,7 +202,7 @@ void CreateCargo::computingBytes(const int16_t& flag, std::vector<char>& input,
|
|||
break;
|
||||
|
||||
case 3:
|
||||
output = crypt.encrypt(cm.compress(input));
|
||||
output = crypt.encrypt(cm.chunked(input, false));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -301,26 +298,6 @@ bool CreateCargo::FindOnTheList(const std::vector<std::string>& list, const std:
|
|||
return it == list.end() ? false : true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Rozdzielanie paternu od œcie¿ki
|
||||
//-----------------------------------------------------------------------------
|
||||
void CreateCargo::ExtPatternAndPathDetection(const std::vector<std::string>& data, std::vector<std::string>& pattern, std::vector<std::string>& path)
|
||||
{
|
||||
for (const auto& d : data)
|
||||
{
|
||||
if (d.front() == '*')
|
||||
{
|
||||
std::string tmpPattern = d;
|
||||
tmpPattern.erase(tmpPattern.begin());
|
||||
pattern.push_back(UpperString(tmpPattern));
|
||||
}
|
||||
else
|
||||
{
|
||||
path.push_back(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sprawdzanie rozszeżeń plików
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -367,69 +344,6 @@ uint64_t CreateCargo::fnv64(const std::string& data)
|
|||
return hash;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sprawdzanie czy plik znajduje siê na liœcie
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CreateCargo::FilteringData(const std::string& path)
|
||||
{
|
||||
std::vector<std::string> cmPatterns;
|
||||
std::vector<std::string> cmPaths;
|
||||
|
||||
// Rozdziel œcie¿ki i patterny na osobne listy
|
||||
ExtPatternAndPathDetection(zipList, cmPatterns, cmPaths);
|
||||
|
||||
if (FindOnTheList(cmPatterns, ALL_FILE))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sprawd¿ czy istnieje plik o danym rozsze¿eniu
|
||||
if (CheckFileExtension(path, cmPatterns))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// SprawdŸ czy instnieje dany plik w danej lokalizacji
|
||||
if (FindOnTheList(cmPaths, path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Kasowanie z listy plików ignorow
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CreateCargo::CheckIgnorePath(const std::string& path)
|
||||
{
|
||||
std::vector<std::string> igPatterns;
|
||||
std::vector<std::string> igPaths;
|
||||
|
||||
ExtPatternAndPathDetection(ignoreList, igPatterns, igPaths);
|
||||
|
||||
// Sprawd¿ czy istnieje plik o danym rozsze¿eniu
|
||||
if (CheckFileExtension(path, igPatterns))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Obrubka œcierzki
|
||||
// Usuwanie katalogu root
|
||||
std::string cleanPath = RemoveStartPath(path);
|
||||
|
||||
// Przekszta³cenie œcierzki na format unixowy
|
||||
std::string unixPath = PathToUnixLike(cleanPath);
|
||||
|
||||
// SprawdŸ czy instnieje dany plik w danej lokalizacji
|
||||
if (FindOnTheList(igPaths, unixPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Trworzenie archiwum
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue