Skip to content

Commit

Permalink
Fix append over replace bug in unlink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightkingale committed May 6, 2024
1 parent 24b8c59 commit 46ed22c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/unlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ bool unlink_account() {
// Process each line in the string.
std::istringstream file_contentstream(file_contents);
std::string line;
std::string processed_contents; // New string to hold the processed content.
while (std::getline(file_contentstream, line)) {
size_t pos = line.find('=');
if (pos != std::string::npos) {
std::string key = line.substr(0, pos);
if (default_values.count(key) > 0)
line = key + "=" + default_values[key];
}
file_contents += line + "\n";
processed_contents += line + "\n"; // Append to processed_contents.
}

// Write the string back to the file.
std::ofstream account_output(ACCOUNT_FILE);
account_output << file_contents;
account_output << processed_contents; // Write processed_contents to the file.
account_output.close();

draw_success_menu("unlink");
Expand Down

0 comments on commit 46ed22c

Please sign in to comment.