-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (34 loc) · 1.13 KB
/
Copy pathmain.cpp
File metadata and controls
41 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <sstream>
#include <string>
#include "FileSystem.h"
using namespace std;
int main() {
FileSystem* fs = new FileSystem();
string input, output, cmd, arg1, arg2;
while(true) {
cmd = arg1 = arg2 = "";
cout << fs->pwd() << "> ";
getline(cin, input);
stringstream ss(input);
ss >> cmd >> arg1 >> arg2;
if (cmd == "exit") break;
else if (cmd == "cd") output = fs->cd(arg1);
else if (cmd == "ls") output = fs->ls();
else if (cmd == "pwd") output = fs->pwd();
else if (cmd == "tree") output = fs->tree();
else if (cmd == "touch") output = fs->touch(arg1);
else if (cmd == "mkdir") output = fs->mkdir(arg1);
else if (cmd == "rm") output = fs->rm(arg1);
else if (cmd == "rmdir") output = fs->rmdir(arg1);
else if (cmd == "mv") output = fs->mv(arg1, arg2);
else if (cmd == "load") {
delete fs;
fs = new FileSystem(arg1);
output = "";
}
else output = "command not found";
if (output != "") cout << output << endl;
}
delete fs;
}