Działa pakowanie zgodne z plikiem konfiguracyjnym

This commit is contained in:
yanczi 2025-11-12 07:38:48 +01:00
parent 621b4b6eb7
commit 00d4b00209
2 changed files with 19 additions and 18 deletions

View file

@ -43,8 +43,6 @@ bool CreateCargo::Create(const std::string& path, const int16_t& flag)
catalogPath = path;
methodFlags = flag;
std::cout << "#1 FLAG: " << flag << " - " << methodFlags << std::endl;
//Sprawdzanie pakowanego kontentu
if (!std::filesystem::is_directory(path))
{
@ -102,11 +100,6 @@ bool CreateCargo::Create(const std::string& path, const int16_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();
@ -119,29 +112,27 @@ bool CreateCargo::GetFileList(const std::string& path)
std::string fileRef = RemoveStartPath(PathToUnixLike(tmpPath));
if (CheckIgnorePath(tmpPath))
{
std::cout << "FLAG: " << methodFlags << std::endl;
PathConf 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(ignoreList, fileRef) || !CheckFileExtension(fileRef, ignoreList))
{
if (FindOnTheList(zipList, fileRef))
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
{
pc.parameter = FindOnTheList(encList, fileRef) ? 3 : 1;
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 3 : 1;
}
else
{
pc.parameter = FindOnTheList(encList, fileRef) ? 2 : 0;
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? 2 : 0;
}
pc.path = PathToUnixLike(tmpPath);
std::cout << pc.parameter << std::endl;
std::cout << pc.path << " - " << pc.parameter << std::endl;
filesPaths.push_back(pc);
}
}
@ -333,10 +324,20 @@ void CreateCargo::ExtPatternAndPathDetection(const std::vector<std::string>& dat
//-----------------------------------------------------------------------------
// Sprawdzanie rozsze¿eñ plików
//-----------------------------------------------------------------------------
bool CreateCargo::CheckFileExtension(const std::filesystem::path& p, const std::vector<std::string>& patterns) {
std::string ext = UpperString(p.extension().string());
bool CreateCargo::CheckFileExtension(const std::string& p, const std::vector<std::string>& patterns) {
std::filesystem::path _p = p;
std::string ext = "*" + UpperString(_p.extension().string());
return FindOnTheList(patterns, ext);
for (const auto& e : patterns)
{
std::string element = UpperString(e);
if (element == ext)
{
return true;
}
}
return false;
}
//-----------------------------------------------------------------------------

View file

@ -120,7 +120,7 @@ private:
bool CheckIgnorePath(const std::string&);
// Sprawdzanie rozsze¿eñ plików
bool CheckFileExtension(const std::filesystem::path&, const std::vector<std::string>&);
bool CheckFileExtension(const std::string&, const std::vector<std::string>&);
// Zamieñ ca³y ci¹g na du¿e litery
std::string UpperString(std::string);