diff --git a/CreateCargo.cpp b/CreateCargo.cpp index 08af63c..4476699 100644 --- a/CreateCargo.cpp +++ b/CreateCargo.cpp @@ -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& dat //----------------------------------------------------------------------------- // Sprawdzanie rozszeżeń plików //----------------------------------------------------------------------------- -bool CreateCargo::CheckFileExtension(const std::filesystem::path& p, const std::vector& patterns) { - std::string ext = UpperString(p.extension().string()); +bool CreateCargo::CheckFileExtension(const std::string& p, const std::vector& 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; } //----------------------------------------------------------------------------- diff --git a/CreateCargo.h b/CreateCargo.h index 2762f30..12fda09 100644 --- a/CreateCargo.h +++ b/CreateCargo.h @@ -120,7 +120,7 @@ private: bool CheckIgnorePath(const std::string&); // Sprawdzanie rozszeżeń plików - bool CheckFileExtension(const std::filesystem::path&, const std::vector&); + bool CheckFileExtension(const std::string&, const std::vector&); // Zamień cały ciąg na duże litery std::string UpperString(std::string);