Add keyboard, create folder, rename folder/file

This commit is contained in:
suchmememanyskill
2020-12-29 16:51:47 +01:00
parent 2302e6111a
commit dfc02f9f81
11 changed files with 307 additions and 9 deletions

View File

@@ -90,10 +90,29 @@ void RunScript(char *path, FSEntry_t entry){
hidWait();
}
void RenameFile(char *path, FSEntry_t entry){
gfx_clearscreen();
char *renameTo = ShowKeyboard(entry.name, false);
if (renameTo == NULL || !(*renameTo)) // smol memory leak but eh
return;
char *src = CombinePaths(path, entry.name);
char *dst = CombinePaths(path, renameTo);
int res = f_rename(src, dst);
if (res){
DrawError(newErrCode(res));
}
free(src);
free(dst);
free(renameTo);
}
fileMenuPath FileMenuPaths[] = {
CopyClipboard,
MoveClipboard,
UnimplementedException,
RenameFile,
DeleteFile,
UnimplementedException,
LaunchPayload,

View File

@@ -64,12 +64,48 @@ int DeleteFolder(const char *path){
return 0;
}
int RenameFolder(const char *path){
char *prev = EscapeFolder(path);
gfx_clearscreen();
char *renameTo = ShowKeyboard(strrchr(path, '/') + 1, false);
if (renameTo == NULL || !(*renameTo)) // smol memory leak but eh
return 0;
char *dst = CombinePaths(prev, renameTo);
int res = f_rename(path, dst);
if (res){
DrawError(newErrCode(res));
}
free(prev);
free(dst);
free(renameTo);
return 1;
}
int CreateFolder(const char *path){
gfx_clearscreen();
char *create = ShowKeyboard("New Folder", true);
if (create == NULL || !(*create)) // smol memory leak but eh
return 0;
char *dst = CombinePaths(path, create);
f_mkdir(dst);
free(dst);
free(create);
return 0;
}
folderMenuPath FolderMenuPaths[] = {
FolderCopyClipboard,
FolderMoveClipboard,
UnimplementedFolderException,
RenameFolder,
DeleteFolder,
UnimplementedFolderException
CreateFolder
};
int FolderMenu(const char *path){