mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
Fix copying files to the root path
This commit is contained in:
parent
1215a19c0b
commit
40ea11d778
@ -127,7 +127,7 @@
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 1
|
||||
#define _FS_RPATH 0
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
@ -146,7 +146,7 @@
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
#define _VOLUME_STRS "SDCARD","CTRNAND_S","TWLN_S","TWLP_S","CTRNAND_E","TWLN_E","TWLP_E" // <--- improve(!!!)
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
|
11
source/fs.c
11
source/fs.c
@ -136,8 +136,11 @@ bool PathCopyWorker(char* dest, char* orig, bool overwrite) {
|
||||
bool ret = false;
|
||||
|
||||
|
||||
if (f_stat(dest, &fno) != FR_OK) return false; // destination directory does not exist
|
||||
if (!(fno.fattrib & AM_DIR)) return false; // destination is not a directory (must be at this point)
|
||||
if (f_stat(dest, &fno) != FR_OK) { // is root or destination does not exist
|
||||
DIR tmp_dir; // check if root
|
||||
if (f_opendir(&tmp_dir, dest) != FR_OK) return false;
|
||||
f_closedir(&tmp_dir);
|
||||
} else if (!(fno.fattrib & AM_DIR)) return false; // destination is not a directory (must be at this point)
|
||||
if (f_stat(orig, &fno) != FR_OK) return false; // origin does not exist
|
||||
|
||||
// build full destination path (on top of destination directory)
|
||||
@ -150,8 +153,10 @@ bool PathCopyWorker(char* dest, char* orig, bool overwrite) {
|
||||
|
||||
// check if destination is part of or equal origin
|
||||
if (strncmp(dest, orig, strnlen(orig, 255)) == 0) {
|
||||
if ((dest[strnlen(orig, 255)] == '/') || (dest[strnlen(orig, 255)] == '\0'))
|
||||
if ((dest[strnlen(orig, 255)] == '/') || (dest[strnlen(orig, 255)] == '\0')) {
|
||||
ShowPrompt(false, "Error: Destination is part of origin");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check if destination exists
|
||||
|
Loading…
x
Reference in New Issue
Block a user