-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (37 loc) · 1.14 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
#include "Huffman.h"
#include "File.h"
enum OperationType {
ENCODE,
DECODE
};
enum CompressionAlgorithm {
HUFFMAN
};
int main(int argc, char** argv)
{
OperationType operationType = OperationType::ENCODE;
CompressionAlgorithm compressionAlgorithm = CompressionAlgorithm::HUFFMAN;
if(std::string(argv[1]) == "encode") operationType = ENCODE;
if(std::string(argv[1]) == "decode") operationType = DECODE;
if(std::string(argv[2]) == "huffman") compressionAlgorithm == CompressionAlgorithm::HUFFMAN;
std::string inputFilepath = std::string(argv[3]);
std::string outputFilepath = std::string(argv[4]);
if(fileExists(inputFilepath))
{
switch(operationType)
{
case OperationType::ENCODE:
std::cout << "Encoding...\n";
HuffmanCompression(inputFilepath, outputFilepath);
break;
case OperationType::DECODE:
std::cout << "Decoding...\n";
HuffmanDecompression(inputFilepath, outputFilepath);
break;
}
}
else
{
std::cout << "ERROR! Invalid filepath";
}
}