blob: c434ba9d5b9e71bb57cf9003cbe4a2b063db81dc (
plain) (
blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
//Name:Reece Warner
//Date:4/24/24
//Assignment:Homework2
#include "Base64Conversion.hpp"
constexpr short ARG_COUNT = 4;
bool Worker();
bool Worker(char** argv);
int main(const int argc, char* argv[])
{
if (argc == ARG_COUNT)
{
//run commandline version
Worker(argv);
}
else
{
//run other version!
}
return Worker(); //can be used to trigger error controls
}
bool Worker()
{
char option = 'e';
switch (option)
{
case 'e':
//file reading binary
//encoding
//file writing text
return true;
case 'd':
//file reading text
//decoding work
//file writing binary
return true;
default:
std::cerr << "Error, invalid command option\n" <<
"Valid commands:\n" <<
"\t -e source_file.exe destination_file.exe" <<
"\tEncodes file in source to text in destination txt file.\n\n" <<
"\t-d source_file.text destination_file.exe" <<
"\tDecodes text in source file into the destination file.\n\n";
return false;
}
return false;
}
bool Worker(char** argv)
{
const char* arg1 = argv[1];//-e or -d
const char* arg2 = argv[2];
const char* arg3 = argv[3];
const char option = arg1[1];
switch (option)
{
case 'e':
//filereading binary
char* buffer = new char[1];
buffer = ReadFileAsBinary(arg2, buffer);
//encoding
//file writing text
delete[] buffer;
return true;
case 'd':
//file readingtext
//decoding work
//file writing binary
return true;
default:
std::cerr << "Error, invalid command option\n" <<
"Valid commands:\n" <<
"\t -e source_file.exe destination_file.exe" <<
"\tEncodes file in source to text in destination txt file.\n\n" <<
"\t-d source_file.text destination_file.exe" <<
"\tDecodes text in source file into the destination file.\n\n";
return false;
}
}
|