From 169eb6c235c3f30f3e06886e80804c38c57d79a7 Mon Sep 17 00:00:00 2001 From: Zastian Pretorius Date: Fri, 31 Dec 2021 12:46:49 +0200 Subject: [PATCH] added -i flag to ignor file tipes from sorting --- main.cpp | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) mode change 100644 => 100755 main.cpp diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index f3e2e9f..6f16312 --- a/main.cpp +++ b/main.cpp @@ -45,7 +45,7 @@ void writeSettins() } //Reads all the lines in settings.toml and saves them in a vector line by line. -std::vector readSettings() +std::vector readSettings(std::vector ignoreList) { std::vector paths; typeAndPaths Paths; @@ -79,16 +79,28 @@ std::vector readSettings() } for(auto it = tbl.begin(); it != tbl.end(); ++it) { - Paths.type = it->first; - Paths.path = tbl[it->first]["path"].ref(); - std::vector extensions; - for(int i = 0 ; i < tbl[it->first]["extensions"].as_array()->size(); i++) - { - std::string ext = tbl[it->first]["extensions"][i].ref(); - extensions.push_back(ext); + std::cout << ignoreList.size() << std::endl; + bool allow = true; + for (int e = 0; e < ignoreList.size(); e++) { + if (ignoreList[e] == std::string(it->first)) + { + allow = false; + break; + } + } + if (allow == true) + { + Paths.type = it->first; + Paths.path = tbl[it->first]["path"].ref(); + std::vector extensions; + for(int i = 0 ; i < tbl[it->first]["extensions"].as_array()->size(); i++) + { + std::string ext = tbl[it->first]["extensions"][i].ref(); + extensions.push_back(ext); + } + Paths.extensions = extensions; + paths.push_back(Paths); } - Paths.extensions = extensions; - paths.push_back(Paths); } } settingsFile.close(); @@ -153,10 +165,19 @@ void sortPath(std::string path, std::vector Paths) } } -int main() +int main(int argc, char *argv[]) { - std::vector TypesAndPaths = readSettings(); + int i = 0; + std::vector ignoreList; + for (i = 0; i < argc; i++) + { + if (std::string(argv[i]) == "-i") { + ignoreList.push_back(argv[i+1]); + } + } + std::vector TypesAndPaths = readSettings(ignoreList); checkSettingsPaths(TypesAndPaths); sortPath(sortingPath, TypesAndPaths); + return 0; }