mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Fix: Backing up NAND from home menu
This commit is contained in:
parent
35c87abf10
commit
5c566ced14
@ -48,7 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GodMode9 version
|
// GodMode9 version
|
||||||
#define VERSION "1.0.2"
|
#define VERSION "1.0.3"
|
||||||
|
|
||||||
// Maximum payload size (arbitrary value!)
|
// Maximum payload size (arbitrary value!)
|
||||||
#define SELF_MAX_SIZE (320 * 1024) // 320kB
|
#define SELF_MAX_SIZE (320 * 1024) // 320kB
|
||||||
|
@ -575,6 +575,7 @@ bool PathCopyVrtToFat(char* dest, char* orig, u32* flags) {
|
|||||||
f_sync(&dfile);
|
f_sync(&dfile);
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
if (flags && (*flags & CALC_SHA)) sha_init(SHA256_MODE);
|
||||||
for (u64 pos = 0; (pos < osize) && ret; pos += MAIN_BUFFER_SIZE) {
|
for (u64 pos = 0; (pos < osize) && ret; pos += MAIN_BUFFER_SIZE) {
|
||||||
UINT read_bytes = min(MAIN_BUFFER_SIZE, osize - pos);
|
UINT read_bytes = min(MAIN_BUFFER_SIZE, osize - pos);
|
||||||
UINT bytes_written = 0;
|
UINT bytes_written = 0;
|
||||||
@ -586,11 +587,20 @@ bool PathCopyVrtToFat(char* dest, char* orig, u32* flags) {
|
|||||||
ret = false;
|
ret = false;
|
||||||
if (read_bytes != bytes_written)
|
if (read_bytes != bytes_written)
|
||||||
ret = false;
|
ret = false;
|
||||||
|
if (flags && (*flags & CALC_SHA))
|
||||||
|
sha_update(MAIN_BUFFER, read_bytes);
|
||||||
}
|
}
|
||||||
ShowProgress(1, 1, orig);
|
ShowProgress(1, 1, orig);
|
||||||
|
|
||||||
fx_close(&dfile);
|
fx_close(&dfile);
|
||||||
if (!ret) f_unlink(dest);
|
if (!ret) f_unlink(dest);
|
||||||
|
else if (flags && (*flags & CALC_SHA)) {
|
||||||
|
u8 sha256[0x20];
|
||||||
|
char* ext_sha = dest + strnlen(dest, 256);
|
||||||
|
strncpy(ext_sha, ".sha", 256 - (ext_sha - dest));
|
||||||
|
sha_get(sha256);
|
||||||
|
FileSetData(dest, sha256, 0x20, 0, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*(--dname) = '\0';
|
*(--dname) = '\0';
|
||||||
@ -600,7 +610,7 @@ bool PathCopyVrtToFat(char* dest, char* orig, u32* flags) {
|
|||||||
bool PathCopyWorker(char* dest, char* orig, u32* flags, bool move) {
|
bool PathCopyWorker(char* dest, char* orig, u32* flags, bool move) {
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if (fa_stat(dest, &fno) != FR_OK) { // is root or destination does not exist
|
if (fa_stat(dest, &fno) != FR_OK) { // is root or destination does not exist
|
||||||
DIR tmp_dir; // check if root
|
DIR tmp_dir; // check if root
|
||||||
if (fa_opendir(&tmp_dir, dest) != FR_OK) return false;
|
if (fa_opendir(&tmp_dir, dest) != FR_OK) return false;
|
||||||
@ -738,6 +748,7 @@ bool PathCopyWorker(char* dest, char* orig, u32* flags, bool move) {
|
|||||||
f_sync(&ofile);
|
f_sync(&ofile);
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
if (flags && (*flags & CALC_SHA)) sha_init(SHA256_MODE);
|
||||||
for (u64 pos = 0; (pos < fsize) && ret; pos += MAIN_BUFFER_SIZE) {
|
for (u64 pos = 0; (pos < fsize) && ret; pos += MAIN_BUFFER_SIZE) {
|
||||||
UINT bytes_read = 0;
|
UINT bytes_read = 0;
|
||||||
UINT bytes_written = 0;
|
UINT bytes_written = 0;
|
||||||
@ -749,12 +760,21 @@ bool PathCopyWorker(char* dest, char* orig, u32* flags, bool move) {
|
|||||||
ret = false;
|
ret = false;
|
||||||
if (bytes_read != bytes_written)
|
if (bytes_read != bytes_written)
|
||||||
ret = false;
|
ret = false;
|
||||||
|
if (flags && (*flags & CALC_SHA))
|
||||||
|
sha_update(MAIN_BUFFER, bytes_read);
|
||||||
}
|
}
|
||||||
ShowProgress(1, 1, orig);
|
ShowProgress(1, 1, orig);
|
||||||
|
|
||||||
fx_close(&ofile);
|
fx_close(&ofile);
|
||||||
fx_close(&dfile);
|
fx_close(&dfile);
|
||||||
if (!ret) f_unlink(dest);
|
if (!ret) f_unlink(dest);
|
||||||
|
else if (flags && (*flags & CALC_SHA)) {
|
||||||
|
u8 sha256[0x20];
|
||||||
|
char* ext_sha = dest + strnlen(dest, 256);
|
||||||
|
strncpy(ext_sha, ".sha", 256 - (ext_sha - dest));
|
||||||
|
sha_get(sha256);
|
||||||
|
FileSetData(dest, sha256, 0x20, 0, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*(--dname) = '\0';
|
*(--dname) = '\0';
|
||||||
|
@ -1099,9 +1099,9 @@ u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboar
|
|||||||
if (emu > 0) optionstr[emu - 1] = "Backup EmuNAND";
|
if (emu > 0) optionstr[emu - 1] = "Backup EmuNAND";
|
||||||
user_select = (n_opt > 1) ? ShowSelectPrompt(n_opt, optionstr, promptstr) : n_opt;
|
user_select = (n_opt > 1) ? ShowSelectPrompt(n_opt, optionstr, promptstr) : n_opt;
|
||||||
if (user_select > 0) {
|
if (user_select > 0) {
|
||||||
u32 flags = CALC_SHA;
|
u32 flags = BUILD_PATH | CALC_SHA;
|
||||||
ShowPrompt(false, "NAND backup: %s",
|
ShowPrompt(false, "NAND backup: %s",
|
||||||
(PathCopy(OUTPUT_PATH, (user_select == sys) ? "1:/nand_min.bin" : "4:/nand_min.bin", &flags)) ?
|
(PathCopy(OUTPUT_PATH, (user_select == sys) ? "S:/nand.bin" : "E:/nand.bin", &flags)) ?
|
||||||
"success" : "failed");
|
"success" : "failed");
|
||||||
GetDirContents(current_dir, current_path);
|
GetDirContents(current_dir, current_path);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user