From ec2b1d414fb150e8689184aac05856554e45a5c9 Mon Sep 17 00:00:00 2001 From: Abir-Tx <28858998+Abir-Tx@users.noreply.github.com> Date: Thu, 22 Oct 2020 18:25:31 +0600 Subject: [PATCH] Add DIR Tree view(#13) & goback globally in #6 Fixes #13 & also Fixes #6 - dowhile loop added for go back option in SFO.cpp - home.hpp: dir view and exit option added - driveLetterTake.hpp: added storing the drive letter in a dat file - dirTree.hpp: created for printing the tree of specified drive --- include/dirTree.hpp | 30 ++++++++++++++++++++++++++++++ include/driveLetterTaker.hpp | 12 ++++++++++++ include/home.hpp | 12 +++++++++++- src/StudyFolderOrgranizer.cpp | 19 +++++++++++++++++-- 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 include/dirTree.hpp diff --git a/include/dirTree.hpp b/include/dirTree.hpp new file mode 100644 index 0000000..8272acf --- /dev/null +++ b/include/dirTree.hpp @@ -0,0 +1,30 @@ +#if !defined(DIRTREE_H) +#define DIRTREE_H +#include +#include +#include +#include + +void dirTree() +{ + using namespace std; + string driveLetterHolder; + + ifstream driveLetterReader("C:\\SFO\\Data\\DriveLetterKeeper.dat"); + + while(getline(driveLetterReader, driveLetterHolder)) + { + driveLetterHolder = driveLetterHolder; + } + + //Starting the dir tree + system("cls"); + system("color 03"); + cout< #include +#include +#include //Global Variables: static std::string driveLetter; @@ -12,6 +14,16 @@ void driveTaker() std::cout << "What is your drive letter: "; std::cin >> driveLetter; + + //Keeping the data in a file for using it in other funcs + //Creating the appData folder: + _mkdir("C:\\SFO"); + _mkdir("C:\\SFO\\Data"); + + //File operation: + std::ofstream driveLetterKeeper("C:\\SFO\\Data\\DriveLetterKeeper.dat"); + driveLetterKeeper< #include #include +#include "../include/dirTree.hpp" //User Defined Headers #include "../include/create.hpp" @@ -28,7 +29,7 @@ void home() std::cout << "Your Options: " << std::endl; - std::vector homeOptions = {"Create Mode", "About"}; + std::vector homeOptions = {"Create Mode", "About", "Directory Tree", "Exit"}; for (int i = 0; i < homeOptions.size(); i++) { @@ -56,6 +57,15 @@ void home() case 2: about(); break; + case 3: + dirTree(); + break; + case 4: + system("cls"); + system("color 04"); + std::cout<<"Exitin the program......."; + exit(0); + break; default: std::cout << "Invalid"; break; diff --git a/src/StudyFolderOrgranizer.cpp b/src/StudyFolderOrgranizer.cpp index 6b6832d..d729676 100644 --- a/src/StudyFolderOrgranizer.cpp +++ b/src/StudyFolderOrgranizer.cpp @@ -4,6 +4,21 @@ Anyone can modify this codes to meet their needs if they like the idea of the so #include #include "../include/home.hpp" -int main(){ - home(); +int main() +{ + int choice; + do + { + home(); + std::cout<> choice; + } while (choice == 1); + if(choice != 1) + { + system("cls"); + system("color 04"); + std::cout<<"Exitin the program......."; + exit(0); + } } \ No newline at end of file