-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
58 lines (49 loc) · 1.29 KB
/
main.c
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
#include <stdio.h>
#include <string.h>
#include "fs.h"
void fs(void){
FTree *ftree = ftree_init();
File d1;
strcpy(d1.file_name, "/");
d1.is_directory = 1;
strcpy(d1.file_content, "root");
File d2;
strcpy(d2.file_name, "bin");
d2.is_directory = 1;
strcpy(d2.file_content, "bin");
File d3;
strcpy(d3.file_name, "etc");
d3.is_directory = 1;
strcpy(d3.file_content, "etc");
File d4;
strcpy(d4.file_name, "man");
d4.is_directory = 0;
strcpy(d4.file_content, "man");
File d5;
strcpy(d5.file_name, "mysql");
d5.is_directory = 0;
strcpy(d5.file_content, "mysql");
File d6;
strcpy(d6.file_name, "mongodb");
d6.is_directory = 0;
strcpy(d6.file_content, "mongodb");
ftree_add(ftree, "/", &d1);
ftree_add(ftree, "/", &d2);
ftree_add(ftree, "/", &d3);
ftree_add(ftree, "/bin", &d4);
ftree_add(ftree, "/usr/db", &d5);
ftree_add(ftree, "/usr/db", &d6);
ftree_traverse(ftree);
printf("%d\n", ftree->size);
if(ftree_is_exist(ftree, "/bin/man"))
printf("/bin/man exists.\n");
if(ftree_is_exist(ftree, "/bin/mount"))
printf("/bin/mount exists.\n");
else
printf("/bin/mount does not exist.\n");
ftree_clear(ftree);
}
int main() {
fs();
return 0;
}