From 2d325fc790e5df58fc6eba484305cdb5515bb491 Mon Sep 17 00:00:00 2001 From: Zastian Pretorius Date: Sat, 23 Oct 2021 21:34:56 +0200 Subject: [PATCH] commented code in main.cpp --- main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index c511889..1ed4ca4 100644 --- a/main.cpp +++ b/main.cpp @@ -2,7 +2,6 @@ #include #include #include -//#include #include std::string musicTypes[] = {".mp3",".wav"}; std::string pictureType[] = {".jpg","jpeg","png"}; @@ -10,6 +9,8 @@ namespace fs = std::filesystem; std::string home = getenv("HOME"); std::string settingsPath = home+"/.config/fsorter/settings.conf"; std::string sortingPath = fs::current_path(); + +//createn of the typeAndPath object class typeAndPaths{ public: std::string type; @@ -17,6 +18,7 @@ class typeAndPaths{ std::vector extentions; }; +//this is just a basic function that will create a basic settings.conf file if it does not exist (it is called by readSettings in the case settings.conf does not exist) void writeSettins() { std::ofstream settings(settingsPath); @@ -27,6 +29,7 @@ void writeSettins() settings.close(); } +//Reads all the lines in settings.conf and saves them in a vector line by line. std::vector readSettings() { if(!fs::exists(settingsPath)) @@ -51,6 +54,8 @@ std::vector readSettings() settings.close(); return listOfPaths; } + +//declarePaths will take a vector of all the text written in settings.conf and devide them in to there respected atrebutes in Object typeAndPath std::vector declarePaths(std::vector listOfPaths) { typeAndPaths Paths; @@ -84,6 +89,9 @@ std::vector declarePaths(std::vector listOfPaths) } return paths; } + +//this will check if the Folder that is mentiond in the object Paths.path (typeAndPath) exists and if not will prompt the user if they want to create the directory or not +//if the user says yes the directory will be created. void checkSettingsPaths(std::vector Paths) { for (int i = 0; i < Paths.size(); i++) @@ -119,6 +127,8 @@ void checkSettingsPaths(std::vector Paths) } } +//iterates thrue all the files in the given path looks at there respected extention and then moves them to the location found in the Paths.path (typeAndPath) object +//that is related to the extention that is being sorted.. void sortPath(std::string path, std::vector Paths) { for(auto const& file: fs::directory_iterator{path})