mirror of
https://github.com/Nightkingale/Wii-U-Account-Swap.git
synced 2026-04-26 08:17:06 -05:00
Add exceptions for more file errors
This commit is contained in:
parent
bdf5724029
commit
5661991590
|
|
@ -70,9 +70,16 @@ write_backup(FILE* account, const std::string& backup_path, char* buffer)
|
|||
// Open the backup file and write the account data to it.
|
||||
rewind(account); // Move the file pointer to the beginning.
|
||||
|
||||
size_t bytesRead = 0;
|
||||
while ((bytesRead = fread(buffer, 1, BUFFER_SIZE, account)) > 0)
|
||||
fwrite(buffer, 1, bytesRead, backup);
|
||||
size_t bytes_read = 0;
|
||||
while ((bytes_read = fread(buffer, 1, BUFFER_SIZE, account)) > 0)
|
||||
fwrite(buffer, 1, bytes_read, backup);
|
||||
|
||||
// Check if there was an error when writing.
|
||||
if (ferror(backup)) {
|
||||
draw_error_menu("Error writing to backup account.dat file!");
|
||||
handle_cleanup(account, backup, buffer, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Close the backup file.
|
||||
fclose(backup);
|
||||
|
|
|
|||
|
|
@ -74,9 +74,21 @@ swap_account(const char* backup_file, account account_type)
|
|||
return false;
|
||||
}
|
||||
|
||||
size_t bytesRead = 0;
|
||||
while ((bytesRead = fread(buffer, 1, BUFFER_SIZE, backup)) > 0)
|
||||
fwrite(buffer, 1, bytesRead, account);
|
||||
size_t bytes_read = 0;
|
||||
while ((bytes_read = fread(buffer, 1, BUFFER_SIZE, backup)) > 0) {
|
||||
if (ferror(backup)) {
|
||||
draw_error_menu("Error reading from backup account.dat file!");
|
||||
handle_cleanup(backup, account_type, buffer, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
fwrite(buffer, 1, bytes_read, account);
|
||||
if (ferror(account)) {
|
||||
draw_error_menu("Error writing to system account.dat file!");
|
||||
handle_cleanup(backup, account_type, buffer, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
fclose(account);
|
||||
|
||||
// We'll attempt to automatically swap the network using Inkay's configuration.
|
||||
|
|
|
|||
|
|
@ -125,6 +125,13 @@ unlink_account()
|
|||
// Write the string back to the file.
|
||||
std::ofstream account_output(ACCOUNT_FILE);
|
||||
account_output << processed_contents; // Write processed_contents to the file.
|
||||
|
||||
if (!account_output.bad()) {
|
||||
draw_error_menu("Error writing to system account.dat file!");
|
||||
OSEnableHomeButtonMenu(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
account_output.close();
|
||||
|
||||
draw_success_menu(success::unlink); // Draw the success menu.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user