diff --git a/source/meme/mainfunctions.c b/source/meme/mainfunctions.c index 7606dcc..e7f04b6 100644 --- a/source/meme/mainfunctions.c +++ b/source/meme/mainfunctions.c @@ -13,20 +13,22 @@ int _openfilemenu(char *path, char *clipboardpath){ meme_clearscreen(); FILINFO fno; f_stat(path, &fno); - char *options[5]; + char *options[6]; int res = 0; int mres = -1; int ret = -1; int i = 4; - bool payload = false; - addchartoarray("Back", options, 0); + addchartoarray("Back\n", options, 0); addchartoarray("Copy to clipboard", options, 1); addchartoarray("Move to clipboard", options, 2); - addchartoarray("Delete file", options, 3); + addchartoarray("Delete file\n", options, 3); if (strstr(path, ".bin") != NULL){ addchartoarray("Launch payload", options, i); - payload = true; + i++; + } + if (strcmp(strstr(path, "emmc:/"), path) == 0){ + addchartoarray("Dump to SD", options, i); i++; } @@ -54,7 +56,12 @@ int _openfilemenu(char *path, char *clipboardpath){ if (mres == 0) f_unlink(path); break; default: - if (payload) launch_payload(path, 0); + if (strcmp(options[res - 1], "Launch payload") == 0) launch_payload(path, 0); + else if (strcmp(options[res - 1], "Dump to SD") == 0) { + int res = 0; + res = dumptosd(path); + if (res == 1) messagebox("Copy Failed\nInput or Output is invalid"); + } } meme_clearscreen(); diff --git a/source/meme/utils.c b/source/meme/utils.c index 4bbad54..b097b2a 100644 --- a/source/meme/utils.c +++ b/source/meme/utils.c @@ -10,7 +10,6 @@ #include "../storage/sdmmc.h" #include "graphics.h" - void utils_gfx_init(){ display_backlight_brightness(100, 1000); gfx_clear_grey(0x1B); @@ -26,6 +25,25 @@ void removepartpath(char *path, char *root){ if (strcmp(path, root) == 0) strcpy(path, temproot); } +int dumptosd(const char *path){ + f_mkdir("sd:/tegraexplorer"); + f_mkdir("sd:/tegraexplorer/nanddump"); + FILINFO fno; + int res = 0; + f_stat(path, &fno); + char pathname[PATHSIZE]; + char foldername[75]; + strcpy(pathname, path); + removepartpath(pathname, "emmc:"); + strcpy(foldername, strrchr(pathname, '/')); + if (strcmp(foldername, "/") == 0) strcpy(foldername, "/root"); + sprintf(pathname, "%s%s", "sd:/tegraexplorer/nanddump", foldername); + f_mkdir(pathname); + sprintf(pathname, "%s%s%s%s", "sd:/tegraexplorer/nanddump", foldername, "/", fno.fname); + res = copy(path, pathname); + return res; +} + void addpartpath(char *path, char *add, char *root){ if (strcmp(path, root) != 0) strcat(path, "/"); strcat(path, add); @@ -153,7 +171,6 @@ int copy(const char *src, const char *dst){ f_unlink(dst); } - free(buff); return 0; diff --git a/source/meme/utils.h b/source/meme/utils.h index 7be5fdc..2ac12a1 100644 --- a/source/meme/utils.h +++ b/source/meme/utils.h @@ -15,4 +15,5 @@ int copy(const char *src, const char *dst); void addchartoarray(char *add, char *items[], int spot); int copywithpath(const char *src, const char *dstpath, int mode, char *app); void return_readable_byte_amounts(unsigned long int size, char *in); -int getfilesize(const char *path); \ No newline at end of file +int getfilesize(const char *path); +int dumptosd(const char *path); \ No newline at end of file