//Chanin Timbal //Homework 2 //27 April 2024 #include #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; }