From a39404ad4b28783978755fba8dfac8254a5fed1d Mon Sep 17 00:00:00 2001 From: Nightkingale <63483138+Nightkingale@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:55:12 -0600 Subject: [PATCH] Rename variables and define functions --- include/backup.h | 1 + include/switch.h | 1 + source/unlink.cpp | 16 ++++++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/backup.h b/include/backup.h index fe15622..07edaa2 100644 --- a/include/backup.h +++ b/include/backup.h @@ -1,6 +1,7 @@ #ifndef BACKUP_H #define BACKUP_H +void writeBackup(FILE* account, const std::string& backupPath, char* buffer); void backupAccount(); #endif // BACKUP_H \ No newline at end of file diff --git a/include/switch.h b/include/switch.h index 594fe2e..9870ca1 100644 --- a/include/switch.h +++ b/include/switch.h @@ -1,6 +1,7 @@ #ifndef SWITCH_H #define SWITCH_H +void handleCleanup(FILE* account, FILE* backup, char* buffer, bool isError); void switchAccount(const char* backupFile, const char* accountType); #endif // SWITCH_H \ No newline at end of file diff --git a/source/unlink.cpp b/source/unlink.cpp index fbb9dc0..8583ddd 100644 --- a/source/unlink.cpp +++ b/source/unlink.cpp @@ -65,15 +65,15 @@ void unlinkAccount() { WHBLogPrint("---------------------------------------------------------"); WHBLogConsoleDraw(); // Read the entire file into a string. - std::ifstream inFile(ACCOUNT_FILE); - std::string fileContents((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); - inFile.close(); + std::ifstream accountInput(ACCOUNT_FILE); + std::string fileContents((std::istreambuf_iterator(accountInput)), std::istreambuf_iterator()); + accountInput.close(); WHBLogPrint("System account.dat file read in memory."); WHBLogConsoleDraw(); // Process each line in the string. - std::istringstream iss(fileContents); + std::istringstream fileContentStream(fileContents); std::string line; - while (std::getline(iss, line)) { + while (std::getline(fileContentStream, line)) { size_t pos = line.find('='); if (pos != std::string::npos) { std::string key = line.substr(0, pos); @@ -86,9 +86,9 @@ void unlinkAccount() { WHBLogPrint("Account file in memory patched."); WHBLogConsoleDraw(); // Write the string back to the file. - std::ofstream outFile(ACCOUNT_FILE); - outFile << fileContents; - outFile.close(); + std::ofstream accountOutput(ACCOUNT_FILE); + accountOutput << fileContents; + accountOutput.close(); WHBLogPrint("System account.dat file written."); WHBLogConsoleDraw(); // Inform the user that the unlink was successful.