mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2025-02-19 23:15:37 +00:00
Handle errors in the main copy loop using a variable
This commit is contained in:
parent
70fe38bd3a
commit
71725059cd
1 changed files with 15 additions and 16 deletions
|
@ -43,43 +43,42 @@ bool dumpPartitionRaw(FsDeviceOperator* fsOperator, u32 partition) {
|
||||||
|
|
||||||
const size_t bufs = 1024 * 1024;
|
const size_t bufs = 1024 * 1024;
|
||||||
char* buf = (char*) malloc(bufs);
|
char* buf = (char*) malloc(bufs);
|
||||||
|
bool success = true;
|
||||||
for (u64 off = 0; off < size; off += bufs) {
|
for (u64 off = 0; off < size; off += bufs) {
|
||||||
u64 n = bufs;
|
u64 n = bufs;
|
||||||
if (size - off < n)
|
if (size - off < n)
|
||||||
n = size - off;
|
n = size - off;
|
||||||
if (R_FAILED(result = fsStorageRead(&gameCardStorage, off, buf, n))) {
|
if (R_FAILED(result = fsStorageRead(&gameCardStorage, off, buf, n))) {
|
||||||
printf("fsStorageRead error\n");
|
printf("\nfsStorageRead error\n");
|
||||||
free(buf);
|
success = false;
|
||||||
fsStorageClose(&gameCardStorage);
|
break;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (fwrite(buf, 1, n, outFile) != n) {
|
if (fwrite(buf, 1, n, outFile) != n) {
|
||||||
printf("fwrite error\n");
|
printf("\nfwrite error\n");
|
||||||
free(buf);
|
success = false;
|
||||||
fsStorageClose(&gameCardStorage);
|
break;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (((off / bufs) % 10) == 0) {
|
if (((off / bufs) % 10) == 0) {
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||||
if (kDown & KEY_B) {
|
if (kDown & KEY_B) {
|
||||||
printf("\nCancelled\n");
|
printf("\nCancelled\n");
|
||||||
free(buf);
|
success = false;
|
||||||
fsStorageClose(&gameCardStorage);
|
break;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(C_CLEAR_LINE "\rDumping %i%% [%li / %li bytes]", (int) (off * 100 / size), off, size);
|
printf(C_CLEAR_LINE "\rDumping %i%% [%li / %li bytes]", (int) (off * 100 / size), off, size);
|
||||||
syncDisplay();
|
syncDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (success) {
|
||||||
|
printf(C_CLEAR_LINE "\rDone!\n");
|
||||||
|
syncDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
printf(C_CLEAR_LINE "\rDone!\n");
|
|
||||||
syncDisplay();
|
|
||||||
|
|
||||||
fclose(outFile);
|
fclose(outFile);
|
||||||
|
|
||||||
fsStorageClose(&gameCardStorage);
|
fsStorageClose(&gameCardStorage);
|
||||||
|
|
||||||
return true;
|
return success;
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue