#include #include #include #include #include #include using namespace std; namespace fs = std::filesystem; struct file_t { string path; uint32_t size; uint32_t offset; }; vector toc; void printHelp() { cout << "Usage: respak2 " << endl; cout << endl << "Valid commands:" << endl; cout << "-p: Pack all files and folders within the 'data' folder into a file named 'data.jf2'." << endl; cout << "-u: Unpack all files inside the file 'data.jf2' into the 'data' folder." << endl; cout << "-l: List the contents of the 'data.jf2' file." << endl; exit(1); } void printErrorAndExit(string errorMsg) { cout << errorMsg << endl; exit(1); } bool createDirectories(const string& dirName) { fs::path path(dirName); std::error_code err; if (!fs::create_directories(path.remove_filename(), err)) { if (fs::exists(path.remove_filename())) { return true; // the folder probably already existed } printf("createDirectories: FAILED to create [%s], err:%s\n", dirName.c_str(), err.message().c_str()); return false; } return true; } void printDirectory(string path, int tabs=0) { for (const auto & entry : fs::directory_iterator(path)) { for(int i=0;i