mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
Prevented a possible bug when unmounting the SD
This commit is contained in:
parent
1501185bdf
commit
50c9091d2c
15
source/fs.c
15
source/fs.c
@ -39,7 +39,7 @@ bool InitNandFS() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeinitFS() {
|
||||
void DeinitNandFS() {
|
||||
for (u32 i = MAX_FS; i > 0; i--) {
|
||||
if (fs_mounted[i]) {
|
||||
char fsname[8];
|
||||
@ -50,6 +50,13 @@ void DeinitFS() {
|
||||
}
|
||||
}
|
||||
|
||||
void DeinitSDCardFS() {
|
||||
if (fs_mounted[0]) {
|
||||
f_mount(NULL, "0:", 1);
|
||||
fs_mounted[0] = false;
|
||||
}
|
||||
}
|
||||
|
||||
int PathToNumFS(const char* path) {
|
||||
int fsnum = *path - (int) '0';
|
||||
if ((fsnum < 0) || (fsnum >= MAX_FS) || (path[1] != ':')) {
|
||||
@ -234,10 +241,12 @@ bool PathCopyWorker(char* dest, char* orig, bool overwrite) {
|
||||
for (size_t pos = 0; (pos < fsize) && ret; pos += MAIN_BUFFER_SIZE) {
|
||||
UINT bytes_read = 0;
|
||||
UINT bytes_written = 0;
|
||||
f_read(&ofile, MAIN_BUFFER, MAIN_BUFFER_SIZE, &bytes_read);
|
||||
if (f_read(&ofile, MAIN_BUFFER, MAIN_BUFFER_SIZE, &bytes_read) != FR_OK)
|
||||
ret = false;
|
||||
if (!ShowProgress(pos + (bytes_read / 2), fsize, orig))
|
||||
ret = false;
|
||||
f_write(&dfile, MAIN_BUFFER, bytes_read, &bytes_written);
|
||||
if (f_write(&dfile, MAIN_BUFFER, bytes_read, &bytes_written) != FR_OK)
|
||||
ret = false;
|
||||
if (bytes_read != bytes_written)
|
||||
ret = false;
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ typedef struct {
|
||||
|
||||
bool InitSDCardFS();
|
||||
bool InitNandFS();
|
||||
void DeinitFS();
|
||||
void DeinitNandFS();
|
||||
void DeinitSDCardFS();
|
||||
|
||||
/** Check if writing to this path is allowed **/
|
||||
bool CheckWritePermissions(const char* path);
|
||||
|
@ -189,7 +189,8 @@ u32 GodMode() {
|
||||
scroll = 0;
|
||||
}
|
||||
} else if ((pad_state & BUTTON_B) && (pad_state & BUTTON_R1)) { // unmount SD card
|
||||
DeinitFS();
|
||||
DeinitNandFS();
|
||||
DeinitSDCardFS();
|
||||
ShowPrompt(false, "SD card unmounted, you can eject now.\nPut it back in before you press <A>.");
|
||||
while (!InitSDCardFS()) {
|
||||
if (!ShowPrompt(true, "Reinitialising SD card failed! Retry?"))
|
||||
@ -336,7 +337,8 @@ u32 GodMode() {
|
||||
}
|
||||
}
|
||||
|
||||
DeinitFS();
|
||||
DeinitNandFS();
|
||||
DeinitSDCardFS();
|
||||
|
||||
return exit_mode;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user