-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
113 lines (108 loc) · 3.63 KB
/
main.cpp
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <stdio.h>
#include <bits/stdc++.h>
#include "src/structures.h"
#include "src/utils.h"
#include "src/format_controller.h"
#include "src/reader.h"
#include "src/reader_controller.h"
#include "src/writer_controller.h"
#include "src/view_mode.h"
#include "src/prints.h"
int main(int argc, const char **argv){
const char *device_name;
const char *directive = argv[1];
if(argc < 2){
print_help();
return 0;
}
else if( !strcmp(directive,"--format") || !strcmp(directive,"-f")){
device_name = argv[2];
if(format(device_name)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else if( !strcmp(directive,"--import") || !strcmp(directive,"-i") ){
const char *file_source_name = argv[2];
const char *device_name = argv[3];
const char *path_into_device = argv[4];
bool root = argc < 5;
if(import_file(file_source_name, device_name, path_into_device, root)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else if(!strcmp(directive,"--view") || !strcmp(directive,"-v") ){
const char *device_name = argv[2];
view_mode(device_name);
return 0;
}
else if(!strcmp(directive,"--help") || !strcmp(directive,"-h")){
print_help();
return 0;
}
else if(!strcmp(directive,"--makeDir") || !strcmp(directive,"-md")){
const char *device_name = argv[2];
const char *path_into_device = argv[3];
if(mk_dir(device_name, path_into_device)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else if(!strcmp(directive,"--remove") || !strcmp(directive,"-r")){
const char *device_name = argv[2];
const char *path_into_device = argv[3];
if(rm_file(device_name, path_into_device)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else if(!strcmp(directive,"--export") || !strcmp(directive,"-e")){
const char *caminho_pasta_destino = argv[2];
const char *device_name = argv[3];
const char *path_into_device = argv[4];
if(export_file(caminho_pasta_destino, device_name, path_into_device)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else if(!strcmp(directive,"--link") || !strcmp(directive,"-l")) {
const char *device_name = argv[2];
const char *file_source_name = argv[3];
const char *path_into_device = argv[4];
bool root = argc < 5;
if(link(device_name,file_source_name,path_into_device,root)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else if(!strcmp(directive,"--hardLink") || !strcmp(directive,"-hl")) {
const char *device_name = argv[2];
const char *file_source_name = argv[3];
const char *path_into_device = argv[4];
bool root = argc < 5;
if(hard_link(device_name,file_source_name,path_into_device,root)){
std::cout << "Sucesso!" << std::endl;
return 0;
}
std::cout << "ERRO!" << std::endl;
return 1;
}
else{
print_help();
return 0;
}
return 0;
}