-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
28 lines (27 loc) · 682 Bytes
/
main.cpp
File metadata and controls
28 lines (27 loc) · 682 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
#include "util.h"
#include "treelib.h"
#include "encrypt.h"
#include "decrypt.h"
int main(int argc, char** argv)
{
//argument checking
if (argc != 4)
error("Input must have 3 arguments");
//input file stream
IStreamWrapper in(*(argv + 2));
//output file stream
OStreamWrapper out(*(argv + 3));
//compress/decompress
std::string option = std::string(*(argv + 1));
//check file integrity
if (!in.good())
error("Bad input file");
//encrypt or decrypt based on input
if (option == "-c")
encrypt(in, out);
else if (option == "-d")
decrypt(in, out);
else
error("Bad option");
return 0;
}