-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
95 lines (82 loc) · 2.24 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
#include <QApplication>
#include "functions.h"
#include "gui.h"
int main(int argc, char *argv[])
{
QList<QString> arg;
for(int i = 0; argv[i]; i++){
arg += argv[i];
}
if(argc == 3 && arg[1] == "-c") {
QString nameFile = arg[2];
compression(nameFile, getNameOut(nameFile));
}
else if(argc == 5 && arg[1] == "-c" && arg[3] == "-o"){
QString nameFileIn = arg[2];
QString nameFileOut = arg[4];
if(isDotHuff(nameFileOut)){
compression(nameFileIn, nameFileOut);
}
else{
help();
}
}
else if(argc == 2 && arg[1] != "--gui"){
QString nameFile = arg[1];
if(isDotHuff(nameFile)){
uncompression(nameFile);
}
else{
qDebug() << "O arquivo não é do tipo .huff";
help();
}
}
else if(argc == 4 && arg[2] == "-d"){
QString nameFile = arg[1];
QString localOut = arg[3];
if(localOut.size() && localOut[localOut.size()-1] != '/') localOut += '/';
if(isDotHuff(nameFile)){
uncompression(nameFile, localOut);
}
else{
qDebug() << "O arquivo não é do tipo .huff";
help();
}
}
else if(argc == 2 && arg[1] == "--gui"){
QApplication a(argc, argv);
Gui w;
w.show();
return a.exec();
}
else if(argc == 2 && (arg[1] == "-h" || arg[1] == "-help")){
help();
}
else if(argc == 3 && arg[1] == "-com"){
QString nameFile = arg[2];
QString nameFileOut = getNameOut(nameFile);
compression(nameFile, nameFileOut);
compression(nameFileOut, nameFileOut);
}
else if(argc == 3 && arg[1] == "-decom"){
QString nameFile = arg[2];
if(isDotHuff(nameFile)){
uncompression(nameFile);
if(isDotHuff(nameFile)){
uncompression(nameFile);
}
else{
qDebug() << "O arquivo não foi comprimido duplamente";
}
}
else{
qDebug() << "O arquivo não é do tipo .huff";
help();
}
}
else{
qDebug() << "COMANDO INVALIDO!\n";
help();
}
return 0;
}