diff options
| author | Chanin Timbal <[email protected]> | 2024-04-27 14:05:17 -0700 |
|---|---|---|
| committer | Chanin Timbal <[email protected]> | 2024-04-27 14:05:17 -0700 |
| commit | f94af69b62058b241e569b973a136afb4d331d46 (patch) | |
| tree | 6333c9062e329593e5d7cae8a1c94bc46391a426 /CST 126/Homework 2/Homework2/program.cpp | |
| parent | Completed Program of Currency Conversion (diff) | |
| download | homework-1-chaninnohea-f94af69b62058b241e569b973a136afb4d331d46.tar.xz homework-1-chaninnohea-f94af69b62058b241e569b973a136afb4d331d46.zip | |
Homework 2 first commit
Diffstat (limited to 'CST 126/Homework 2/Homework2/program.cpp')
| -rw-r--r-- | CST 126/Homework 2/Homework2/program.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/CST 126/Homework 2/Homework2/program.cpp b/CST 126/Homework 2/Homework2/program.cpp new file mode 100644 index 0000000..158a2be --- /dev/null +++ b/CST 126/Homework 2/Homework2/program.cpp @@ -0,0 +1,70 @@ +//Chanin Timbal +//Homework 2 +//27 April 2024 + +#include <iostream> + +#include "helpers.hpp" +#include "Base64Converter.hpp" + +constexpr short ARG_COUNT = 4; + +bool Worker(); +bool Worker(char** argv); + + + +int main(const int argc, char* argv[]) +{ + if (argc == ARG_COUNT) + { + //run the command line version + Worker(argv); + } + return Worker(); +} + +bool Worker() +{ +} + +bool Worker(char** argv) +{ + const char* arg1 = argv[1]; //-e -d + const char* arg2 = argv[2]; //source file name + const char* arg3 = argv[3]; //destination file name + + const char option = arg1[1]; //e or d + + switch (option) + { + case 'e': + //file reading binary + char* buffer = new char[1]; + + buffer = ReadFileAsBinary(arg2, buffer); + //endcoding work + + bool success = WriteTextToFile(arg3, buffer); + + delete[] buffer; + + return success; + case 'd': + //file reading text + //decoding work + //file writing binary + return true; + default: + std::cerr << "Invalid command option\n" << + "Valid commands:\n" << + "\t-e source_file.exe destination_file.exe" << + "\t\tEncodes file in source into text in destination txt file." << + "\t-d source_file.txt destination file.exe" << + "\t\tDecodes text in source file into the destination file.\n\n"; + return false; + } + + + return false; +}
\ No newline at end of file |