-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (35 loc) · 730 Bytes
/
Copy pathmain.cpp
File metadata and controls
41 lines (35 loc) · 730 Bytes
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
#include "huffman.h"
bool fileExists(string fileName)
{
fstream infile(fileName.c_str());
return infile.good();
}
int main(int argc, char *argv[])
{
if(argc!=3)
{
cout<<"Wrong number of arguments provided."<<endl<<"Usage:'./app.exe <-(c/d)> <filepath>";
return -1;
}
string mode = argv[1];
string fileName = argv[2];
if(!fileExists(fileName))
{
cout<<"File doesn't exist"<<endl;
return -1;
}
Huffman h;
if(mode=="-c")
{
h.compressFile(fileName);
}
else if(mode=="-d")
{
h.decompressFile(fileName);
}
else
{
cout<<"Invalid mode entered"<<endl;
return -1;
}
}