aboutsummaryrefslogtreecommitdiff
path: root/CST 126/Homework2/main.cpp
diff options
context:
space:
mode:
authorrPatrickWarner <[email protected]>2024-04-27 12:57:15 -0700
committerrPatrickWarner <[email protected]>2024-04-27 12:57:15 -0700
commitb7688d74869d4606913f5ff197c19183d0ef0aff (patch)
tree467a6c77bb2d04aa8239fe4f8766b93ed1178084 /CST 126/Homework2/main.cpp
parentinit (diff)
downloadhomework-1-reecepwarner-b7688d74869d4606913f5ff197c19183d0ef0aff.tar.xz
homework-1-reecepwarner-b7688d74869d4606913f5ff197c19183d0ef0aff.zip
Added binary file reading function
Diffstat (limited to 'CST 126/Homework2/main.cpp')
-rw-r--r--CST 126/Homework2/main.cpp79
1 files changed, 75 insertions, 4 deletions
diff --git a/CST 126/Homework2/main.cpp b/CST 126/Homework2/main.cpp
index 1d71629..c434ba9 100644
--- a/CST 126/Homework2/main.cpp
+++ b/CST 126/Homework2/main.cpp
@@ -1,19 +1,90 @@
//Name:Reece Warner
//Date:4/24/24
//Assignment:Homework2
+#include "Base64Conversion.hpp"
-#include <fstream>
-#include <iostream>
+constexpr short ARG_COUNT = 4;
+bool Worker();
+bool Worker(char** argv);
-int main(int argc, 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];
- return 0;
+ 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;
+ }
} \ No newline at end of file