Add fw dumping

- also fatfs is stupid
- also close files properly on a failed copy
- also check for errors during folder readouts
- also make sure holding vol- doesn't dump the keys anyway
This commit is contained in:
suchmememanyskill
2020-12-28 02:29:58 +01:00
parent 859ad2cc4c
commit 513bd804b1
18 changed files with 222 additions and 29 deletions

View File

@@ -30,13 +30,7 @@ MenuEntry_t MakeMenuOutFSEntry(FSEntry_t entry){
return out;
}
void clearFileVector(Vector_t *v){
vecPDefArray(FSEntry_t*, entries, v);
for (int i = 0; i < v->count; i++)
free(entries[i].name);
free(v->data);
}
void FileExplorer(char *path){
char *storedPath = CpyStr(path);
@@ -48,8 +42,15 @@ void FileExplorer(char *path){
gfx_clearscreen();
gfx_printf("Loading...\r");
//gfx_printf(" ");
Vector_t fileVec = ReadFolder(storedPath);
int readRes = 0;
Vector_t fileVec = ReadFolder(storedPath, &readRes);
if (readRes){
clearFileVector(&fileVec);
DrawError(newErrCode(readRes));
return;
}
vecDefArray(FSEntry_t*, fsEntries, fileVec);
topEntries[0].name = storedPath;

View File

@@ -10,6 +10,7 @@
#include "../../hid/hid.h"
#include <libs/fatfs/ff.h>
#include "../../utils/utils.h"
#include "../../keys/nca.h"
MenuEntry_t FileMenuEntries[] = {
// Still have to think up the options
@@ -50,17 +51,12 @@ void MoveClipboard(char *path, FSEntry_t entry){
free(thing);
}
MenuEntry_t DeleteEntries[] = {
{.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "No"},
{.R = 255, .name = "Yes"}
};
void DeleteFile(char *path, FSEntry_t entry){
gfx_con_setpos(384 + 16, 200 + 16 + 10 * 16);
SETCOLOR(COLOR_RED, COLOR_DARKGREY);
gfx_printf("Are you sure? ");
if (!MakeHorizontalMenu(DeleteEntries, 2, 3, COLOR_DARKGREY))
if (!MakeYesNoHorzMenu(3, COLOR_DARKGREY))
return;
char *thing = CombinePaths(path, entry.name);