1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00

add dump to sd file option

This commit is contained in:
Such Meme, Many Skill 2019-08-20 01:26:39 +02:00
parent d000f86c89
commit 9281e4bbbc
3 changed files with 34 additions and 9 deletions

View file

@ -13,20 +13,22 @@ int _openfilemenu(char *path, char *clipboardpath){
meme_clearscreen(); meme_clearscreen();
FILINFO fno; FILINFO fno;
f_stat(path, &fno); f_stat(path, &fno);
char *options[5]; char *options[6];
int res = 0; int res = 0;
int mres = -1; int mres = -1;
int ret = -1; int ret = -1;
int i = 4; int i = 4;
bool payload = false;
addchartoarray("Back", options, 0); addchartoarray("Back\n", options, 0);
addchartoarray("Copy to clipboard", options, 1); addchartoarray("Copy to clipboard", options, 1);
addchartoarray("Move to clipboard", options, 2); addchartoarray("Move to clipboard", options, 2);
addchartoarray("Delete file", options, 3); addchartoarray("Delete file\n", options, 3);
if (strstr(path, ".bin") != NULL){ if (strstr(path, ".bin") != NULL){
addchartoarray("Launch payload", options, i); addchartoarray("Launch payload", options, i);
payload = true; i++;
}
if (strcmp(strstr(path, "emmc:/"), path) == 0){
addchartoarray("Dump to SD", options, i);
i++; i++;
} }
@ -54,7 +56,12 @@ int _openfilemenu(char *path, char *clipboardpath){
if (mres == 0) f_unlink(path); if (mres == 0) f_unlink(path);
break; break;
default: 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(); meme_clearscreen();

View file

@ -10,7 +10,6 @@
#include "../storage/sdmmc.h" #include "../storage/sdmmc.h"
#include "graphics.h" #include "graphics.h"
void utils_gfx_init(){ void utils_gfx_init(){
display_backlight_brightness(100, 1000); display_backlight_brightness(100, 1000);
gfx_clear_grey(0x1B); gfx_clear_grey(0x1B);
@ -26,6 +25,25 @@ void removepartpath(char *path, char *root){
if (strcmp(path, root) == 0) strcpy(path, temproot); 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){ void addpartpath(char *path, char *add, char *root){
if (strcmp(path, root) != 0) strcat(path, "/"); if (strcmp(path, root) != 0) strcat(path, "/");
strcat(path, add); strcat(path, add);
@ -153,7 +171,6 @@ int copy(const char *src, const char *dst){
f_unlink(dst); f_unlink(dst);
} }
free(buff); free(buff);
return 0; return 0;

View file

@ -16,3 +16,4 @@ void addchartoarray(char *add, char *items[], int spot);
int copywithpath(const char *src, const char *dstpath, int mode, char *app); int copywithpath(const char *src, const char *dstpath, int mode, char *app);
void return_readable_byte_amounts(unsigned long int size, char *in); void return_readable_byte_amounts(unsigned long int size, char *in);
int getfilesize(const char *path); int getfilesize(const char *path);
int dumptosd(const char *path);