From cb7c21fb72045a396564f16ebf0065d4b7be9d86 Mon Sep 17 00:00:00 2001 From: Zastian Pretorius Date: Fri, 22 Oct 2021 19:37:12 +0200 Subject: [PATCH] made it possobe to read from settings.conf --- .gitignore | 1 + main.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/.gitignore b/.gitignore index fbff541..6d3f1b5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tmp/ fsorter .ccls-cache/ CMakeFiles/ +settings.conf diff --git a/main.cpp b/main.cpp index cae12df..290bf26 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,72 @@ #include #include #include +#include //#include #include + namespace fs = std::filesystem; +std::string settingsPath = "settings.conf"; +std::string musicPath() +{ + std::string musicFolder = ""; + return musicFolder; +} + +std::string photoPath() +{ + std::string photoFolder = ""; + return photoFolder; +} + +std::string videoPath() +{ + std::string videoFolder = ""; + return videoFolder; +} + +std::string arcivePath() +{ + std::string arciveFolder = ""; + return arciveFolder; +} +void writeSettins() +{ + std::ofstream settings(settingsPath); + settings << "Pictures=\n$HOME/Pictures" << std::endl; + settings << "Music=\n$HOME/Music" << std::endl; + settings.close(); + + +} +std::vector readSettings() +{ + + std::ifstream settings(settingsPath); + std::vector listOfPaths; + std::string setting; + // creates a default settins file + if(!settings) + { + writeSettins(); + } + if(settings) + { + while(getline(settings, setting)) + { + listOfPaths.push_back(setting); + } + } + return listOfPaths; +} int main() { + std::vector listOfPaths = readSettings(); + for (int i; i < listOfPaths.size(); i++) { + std::string stringItem ="echo " + listOfPaths[1]; + const char* item = stringItem.c_str(); + system(item); + } return 0; }