Skip to content

Commit 168582f

Browse files
committed
Better clipboard handling on unmounts
1 parent b4d3b6f commit 168582f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

source/godmode.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
#include "virtual.h"
88
#include "image.h"
99

10-
#define VERSION "0.7.2"
10+
#define VERSION "0.7.3"
1111

1212
#define N_PANES 2
13-
#define IMG_DRV "789I"
1413

1514
#define WORK_BUFFER ((u8*)0x21100000)
1615

@@ -690,6 +689,8 @@ u32 GodMode() {
690689
clipboard->n_entries = 0;
691690
}
692691
} else if ((int) user_select == mountable) { // -> mount as image
692+
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & DRV_IMAGE))
693+
clipboard->n_entries = 0; // remove last mounted image clipboard entries
693694
DeinitExtFS();
694695
u32 mount_state = MountImage(curr_entry->path);
695696
InitExtFS();
@@ -703,8 +704,6 @@ u32 GodMode() {
703704
GetDirContents(current_dir, current_path);
704705
cursor = 0;
705706
}
706-
if (clipboard->n_entries && (strcspn(clipboard->entry[0].path, IMG_DRV) == 0))
707-
clipboard->n_entries = 0; // remove invalid clipboard stuff
708707
} else if ((int) user_select == searchdrv) { // -> search drive, open containing path
709708
char* last_slash = strrchr(curr_entry->path, '/');
710709
if (last_slash) {
@@ -735,11 +734,12 @@ u32 GodMode() {
735734
}
736735
}
737736
} else if (switched && (pad_state & BUTTON_B)) { // unmount SD card
737+
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & (DRV_SDCARD|DRV_ALIAS|DRV_EMUNAND|DRV_IMAGE)))
738+
clipboard->n_entries = 0; // remove SD clipboard entries
738739
DeinitExtFS();
739740
if (GetMountState() != IMG_RAMDRV)
740741
MountImage(NULL);
741742
DeinitSDCardFS();
742-
clipboard->n_entries = 0;
743743
memset(panedata, 0x00, N_PANES * sizeof(PaneData));
744744
ShowString("SD card unmounted, you can eject now.\n \n<R+Y+\x1B> for format menu\n<A> to remount SD card");
745745
while (true) {
@@ -798,13 +798,13 @@ u32 GodMode() {
798798
// highly specific commands
799799
if (!*current_path) { // in the root folder...
800800
if (switched && (pad_state & BUTTON_X)) { // unmount image
801+
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & DRV_IMAGE))
802+
clipboard->n_entries = 0; // remove last mounted image clipboard entries
801803
DeinitExtFS();
802804
if (!GetMountState()) MountRamDrive();
803805
else MountImage(NULL);
804806
InitExtFS();
805807
GetDirContents(current_dir, current_path);
806-
if (clipboard->n_entries && (strcspn(clipboard->entry[0].path, IMG_DRV) == 0))
807-
clipboard->n_entries = 0; // remove invalid clipboard stuff
808808
} else if (switched && (pad_state & BUTTON_Y)) {
809809
SetWritePermissions((GetWritePermissions() > PERM_BASE) ? PERM_BASE : PERM_ALL, false);
810810
}
@@ -937,6 +937,8 @@ u32 GodMode() {
937937
exit_mode = GODMODE_EXIT_REBOOT;
938938
break;
939939
} else if (user_select == 3) {
940+
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & (DRV_SDCARD|DRV_ALIAS|DRV_EMUNAND|DRV_IMAGE)))
941+
clipboard->n_entries = 0; // remove SD clipboard entries
940942
DeinitExtFS();
941943
if (GetMountState() != IMG_RAMDRV)
942944
MountImage(NULL);

0 commit comments

Comments
 (0)