Skip to content

Commit

Permalink
Merge pull request #18 from Abir-Tx/Abir-Tx/issue13 & issue6
Browse files Browse the repository at this point in the history
Add DIR Tree view(#13) & goback globally in #6
  • Loading branch information
Abir-Tx committed Oct 22, 2020
2 parents 10ec881 + ec2b1d4 commit 1e7250c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
30 changes: 30 additions & 0 deletions include/dirTree.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#if !defined(DIRTREE_H)
#define DIRTREE_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <iostream>

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<<setw(75)<<setfill(' ')<<"Directory Tree Viewer"<<endl<<endl;

cout<<"Printing the folders structure view inside the selected drive: "<<endl;
std::cout<<std::endl;
string treeDir = "tree /f "+driveLetterHolder+":\\\"University Study\"";
system(treeDir.c_str());
}
#endif // DIRTREE_H
12 changes: 12 additions & 0 deletions include/driveLetterTaker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define DRIVELETTERTAKER_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <direct.h>

//Global Variables:
static std::string driveLetter;
Expand All @@ -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<<driveLetter;
driveLetterKeeper.close();
}

#endif // DRIVELETTERTAKER_H
12 changes: 11 additions & 1 deletion include/home.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <vector>
#include <direct.h>
#include <iomanip>
#include "../include/dirTree.hpp"

//User Defined Headers
#include "../include/create.hpp"
Expand All @@ -28,7 +29,7 @@ void home()

std::cout << "Your Options: " << std::endl;

std::vector<std::string> homeOptions = {"Create Mode", "About"};
std::vector<std::string> homeOptions = {"Create Mode", "About", "Directory Tree", "Exit"};

for (int i = 0; i < homeOptions.size(); i++)
{
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 17 additions & 2 deletions src/StudyFolderOrgranizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Anyone can modify this codes to meet their needs if they like the idea of the so
#include <iostream>
#include "../include/home.hpp"

int main(){
home();
int main()
{
int choice;
do
{
home();
std::cout<<std::endl;
std::cout << "Press 1 to go to homepage again & others to Exit: ";
std::cin >> choice;
} while (choice == 1);
if(choice != 1)
{
system("cls");
system("color 04");
std::cout<<"Exitin the program.......";
exit(0);
}
}

0 comments on commit 1e7250c

Please sign in to comment.