Skip to content

Commit

Permalink
Rename variables and define functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightkingale committed Apr 13, 2024
1 parent 4b80f50 commit a39404a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/backup.h
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions include/switch.h
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions source/unlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(inFile)), std::istreambuf_iterator<char>());
inFile.close();
std::ifstream accountInput(ACCOUNT_FILE);
std::string fileContents((std::istreambuf_iterator<char>(accountInput)), std::istreambuf_iterator<char>());
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);
Expand All @@ -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.
Expand Down

0 comments on commit a39404a

Please sign in to comment.