mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 21:52:48 +00:00
Also check write permissions for creating folders / renaming files
Plus: Don't allow renaming virtual FAT entries
This commit is contained in:
parent
38fccfb28b
commit
f44472fd0a
@ -291,6 +291,7 @@ bool PathDelete(const char* path) {
|
|||||||
bool PathRename(const char* path, const char* newname) {
|
bool PathRename(const char* path, const char* newname) {
|
||||||
char npath[256]; // 256 is the maximum length of a full path
|
char npath[256]; // 256 is the maximum length of a full path
|
||||||
char* oldname = strrchr(path, '/');
|
char* oldname = strrchr(path, '/');
|
||||||
|
if (!CheckWritePermissions(path)) return false;
|
||||||
if (!oldname) return false;
|
if (!oldname) return false;
|
||||||
oldname++;
|
oldname++;
|
||||||
strncpy(npath, path, oldname - path);
|
strncpy(npath, path, oldname - path);
|
||||||
@ -300,6 +301,7 @@ bool PathRename(const char* path, const char* newname) {
|
|||||||
|
|
||||||
bool DirCreate(const char* cpath, const char* dirname) {
|
bool DirCreate(const char* cpath, const char* dirname) {
|
||||||
char npath[256]; // 256 is the maximum length of a full path
|
char npath[256]; // 256 is the maximum length of a full path
|
||||||
|
if (!CheckWritePermissions(cpath)) return false;
|
||||||
snprintf(npath, 255, "%s/%s", cpath, dirname);
|
snprintf(npath, 255, "%s/%s", cpath, dirname);
|
||||||
return (f_mkdir(npath) == FR_OK);
|
return (f_mkdir(npath) == FR_OK);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ u32 GodMode() {
|
|||||||
ClearScreenF(true, false, COLOR_STD_BG);
|
ClearScreenF(true, false, COLOR_STD_BG);
|
||||||
}
|
}
|
||||||
} else { // switched command set
|
} else { // switched command set
|
||||||
if (pad_state & BUTTON_X) { // rename a file
|
if ((pad_state & BUTTON_X) && cursor) { // rename a file
|
||||||
char newname[256];
|
char newname[256];
|
||||||
char namestr[20+1];
|
char namestr[20+1];
|
||||||
TruncateString(namestr, current_dir->entry[cursor].name, 20, 12);
|
TruncateString(namestr, current_dir->entry[cursor].name, 20, 12);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user