mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Improved copy-overwrite handling
This commit is contained in:
parent
df82754a6a
commit
f574549cdb
11
source/fs.c
11
source/fs.c
@ -114,7 +114,7 @@ bool FileCreate(const char* path, u8* data, u32 size) {
|
|||||||
return (bytes_written == size);
|
return (bytes_written == size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathCopyWorker(char* dest, char* orig) {
|
bool PathCopyWorker(char* dest, char* orig, bool overwrite) {
|
||||||
FILINFO fno = {.lfname = NULL};
|
FILINFO fno = {.lfname = NULL};
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
@ -138,11 +138,12 @@ bool PathCopyWorker(char* dest, char* orig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if destination exists
|
// check if destination exists
|
||||||
if (f_stat(dest, NULL) == FR_OK) {
|
if (!overwrite && (f_stat(dest, NULL) == FR_OK)) {
|
||||||
char namestr[40];
|
char namestr[36 + 1];
|
||||||
TruncateString(namestr, dest, 36, 8);
|
TruncateString(namestr, dest, 36, 8);
|
||||||
if (!ShowPrompt(true, "Destination already exists:\n%s\nOverwrite existing file(s)?", namestr))
|
if (!ShowPrompt(true, "Destination already exists:\n%s\nOverwrite existing file(s)?", namestr))
|
||||||
return false;
|
return false;
|
||||||
|
overwrite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the copy process takes place here
|
// the copy process takes place here
|
||||||
@ -169,7 +170,7 @@ bool PathCopyWorker(char* dest, char* orig) {
|
|||||||
if (fno.fname[0] == 0) {
|
if (fno.fname[0] == 0) {
|
||||||
ret = true;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
} else if (!PathCopyWorker(dest, orig)) {
|
} else if (!PathCopyWorker(dest, orig, overwrite)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +223,7 @@ bool PathCopy(const char* destdir, const char* orig) {
|
|||||||
if (!CheckWritePermissions(destdir)) return false;
|
if (!CheckWritePermissions(destdir)) return false;
|
||||||
strncpy(fdpath, destdir, 255);
|
strncpy(fdpath, destdir, 255);
|
||||||
strncpy(fopath, orig, 255);
|
strncpy(fopath, orig, 255);
|
||||||
return PathCopyWorker(fdpath, fopath);
|
return PathCopyWorker(fdpath, fopath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathDeleteWorker(char* fpath) {
|
bool PathDeleteWorker(char* fpath) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user