-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
97 lines (85 loc) · 2.6 KB
/
Copy pathMain.cpp
File metadata and controls
97 lines (85 loc) · 2.6 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
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <cstring>
#include <ctime>
#include <vector>
#include "Compress.h"
#include "deCompress.h"
int main()
{
bool flag;
std::string Compress_filename, deCompress_filename, Original_filename;
while (true)
{
std::cout << "\t____________________________________________\n";
std::cout << "\t|__________________________________________|\n";
std::cout << "\t|_________Press 'C' to Compress file_______|\n";
std::cout << "\t|_________Press 'D' to deCompress file_____|\n";
std::cout << "\t|_________Press 'Q' to Quit _______________|\n";
std::cout << "\t|__________________________________________|\n";
std::cout << "\t|__________________________________________|\n";
std::cout << "\n";
char choice;
do
{
std::cout << "Please selece a function\n";
std::cin >> choice;
choice = toupper(choice);
if (choice != 'C' && choice != 'D' && choice != 'Q')
std::cout << "Input error, please enter again\n";
} while (choice != 'C' && choice != 'D' && choice != 'Q');
if (choice == 'Q')break;
else if (choice == 'C')
{
clock_t begin_Compress, end_Compress;
std::cout << "Please enter the filename to be compressed: ";
std::cin >> Compress_filename;
std::cout << "\n";
std::cout << "Please enter the filename to store the decompressd data: ";
std::cin >> deCompress_filename;
std::cout << "\n";
begin_Compress = clock();
std::cout << "Compressing...\n";
flag = Compress(Compress_filename, deCompress_filename);
end_Compress = clock();
std::cout << "\n";
if (flag == false)
{
std::cout << "Fail to open the file\n";
exit(1);
}
else
{
std::cout << "Compress completed\ntotal time elapsed: " << (end_Compress - begin_Compress) / 1000.0 << "/s\n";
}
}
else if (choice == 'D')
{
clock_t begin_deCompress, end_deCompress;
std::cout << "Please enter the filename to be decompressed: ";
std::cin >> deCompress_filename;
std::cout << "\n";
std::cout << "Please enter the filename to store the data: ";
std::cin >> Original_filename;
std::cout << "\n";
begin_deCompress = clock();
std::cout << "deCompressing...\n";
flag = deCompress(deCompress_filename, Original_filename);
end_deCompress = clock();
std::cout << "\n";
if (flag == false)
{
std::cout << "Fail to open the file\n";
exit(1);
}
else
{
std::cout << "deCompress completed\ntotal time elapsed: " << (end_deCompress - begin_deCompress) / 1000.0 << "/s\n";
}
}
std::cout << "Press any key to continue\n";
system("pause");
system("cls");
}
std::cout << "Thank you for using\n";
return 0;
}