-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (62 loc) · 2.18 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (62 loc) · 2.18 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// Created on 11/13/18.
//
#include<iostream>
#include "RBTree.h"
#include "Folder.h"
using namespace std;
int main() {
/*ASSUMPTIONS
* FILE NAMES ARE CASE SENSITIVE
*/
Folder* root = new Folder("");
// ADD FOLDERS AND FILES
root->add_file("/", "a.txt", 1);
root->add_file("/", "ab.txt", 2);
root->add_file("/", "c.txt", 3);
root->add_folder("/", "child1");
root->add_folder("/", "child2");
root->add_folder("/", "child3");
root->add_file("/child1/", "a.txt", 1);
root->add_file("/child1/", "b.txt", 2);
root->add_file("/child1/", "c.txt", 3);
root->add_file("/child2/", "a.txt", 1);
root->add_file("/child2/", "b.txt", 2);
root->add_file("/child2/", "c.txt", 3);
root->add_file("/child3/", "a.txt", 1);
root->add_file("/child3/", "b.txt", 2);
root->add_file("/child3/", "c.txt", 3);
// GET FILES AND FILE
cout << endl << "Get files from child1:" << endl;
list<Node> files = root->get_files("/child1/");
for(auto it = files.begin(); it != files.end(); it++) {
cout << it->name << endl;
}
cout << endl << "Get files from child2:" << endl;
files = root->get_files("/child2/");
for(auto it = files.begin(); it != files.end(); it++) {
cout << it->name << endl;
}
cout << endl << "Get files from child3:" << endl;
files = root->get_files("/child3/");
for(auto it = files.begin(); it != files.end(); it++) {
cout << it->name << endl;
}
cout << endl << "Get file from child1" << endl;
Node tmp = root->get_file("/child1/", "c.txt");
cout << "File Name: " << tmp.name << endl << endl;
cout << "Delete /child3/c.txt file" << endl;
root->delete_file("/child3/", "c.txt");
cout << "Get files from child3:" << endl;
files = root->get_files("/child3/");
for(auto it = files.begin(); it != files.end(); it++) {
cout << it->name << endl;
}
cout << "Delete folder /child2/" << endl;
root->delete_folder("/child2/");
cout << "Print root's child folders" << endl;
for(auto it = root->childFolders.begin(); it != root->childFolders.end(); it++) {
cout << (*it)->name << ", ";
}
return 0;
}