-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (43 loc) · 1.26 KB
/
main.cpp
File metadata and controls
49 lines (43 loc) · 1.26 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
#include "Compressor.h"
#include "Decompressor.h"
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main(int argc, char const *argv[])
{
if (argc < 3)
{
std::cerr << "Insufficient number of arguments entered." << '\n';
return -1;
}
fs::path file_path = argv[1];
std::string action = argv[2];
try
{
if (action == "compress")
{
std::cout << "Compressing File " + file_path.filename().string() + " ..." << std::endl;
Compressor *compressor = new Compressor(file_path);
delete compressor;
std::cout << "File Compressed Successfully!" << std::endl;
}
else if (action == "decompress")
{
std::cout << "Decompressing File " + file_path.filename().string() + " ..." << std::endl;
Decompressor *decompressor = new Decompressor(file_path);
delete decompressor;
std::cout << "File Decompressed Successfully!" << std::endl;
}
else
{
std::cerr << "Non-existent action." << '\n';
return -1;
}
}
catch (const std::exception &e)
{
std::cerr << "Error: " << e.what() << '\n';
return -1;
}
return 0;
}