-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (44 loc) · 1.46 KB
/
main.cpp
File metadata and controls
50 lines (44 loc) · 1.46 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
#include <iostream>
#include "include/Huffman.h"
using namespace std;
int main(int argc, char *argv[])
{
// Usage: ./byteshrink -c input.txt compressed.bin
if (argc < 4)
{
cout << "=== ByteShrink CLI v1.0 ===" << endl;
cout << "Usage: " << argv[0] << " [flag] <input_file> <output_file>" << endl;
cout << "Flags:" << endl;
cout << " -c : Compress a text file to binary" << endl;
cout << " -d : Decompress a binary file to text" << endl;
return 1;
}
string flag = argv[1];
string inputFile = argv[2];
string outputFile = argv[3];
if (flag == "-c")
{
cout << "Compressing: " << inputFile << " -> " << outputFile << "..." << endl;
Compress(inputFile, outputFile);
cout << "Compression successful!" << endl;
}
else if (flag == "-d")
{
cout << "Decompressing: " << inputFile << " -> " << outputFile << "..." << endl;
Decompresss(inputFile, outputFile);
cout << "Decompression successful!" << endl;
}
else
{
cout << "Error: Invalid flag '" << flag << "'. Use -c or -d." << endl;
return 1;
}
return 0;
}
/*
COMMANDS
to Compile - g++ main.cpp src/Huffman.cpp src/RLE.cpp src/FileM.cpp -Iinclude -o byteshrink
to Compress - ./byteshrink -c input.txt compressed.bin
to Decompress - ./byteshrink -d compressed.bin restored.txt
to Check - fc.exe input.txt restored.txt
*/