mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 20:06:43 +00:00
Implement folder options (Delete folder)
This commit is contained in:
parent
3e8cd67129
commit
e1f4c24686
4 changed files with 147 additions and 55 deletions
|
@ -29,6 +29,13 @@ menu_item explfilemenu[9] = {
|
||||||
{"View Hex", COLOR_GREEN, HEXVIEW, 1}
|
{"View Hex", COLOR_GREEN, HEXVIEW, 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
menu_item explfoldermenu[4] = {
|
||||||
|
{"-- Folder Menu --\n", COLOR_BLUE, -1, 0},
|
||||||
|
{"Back", COLOR_WHITE, -1, 1},
|
||||||
|
{"Return to main menu\n", COLOR_BLUE, EXITFOLDER, 1},
|
||||||
|
{"Delete folder", COLOR_RED, DELETEFOLDER, 1}
|
||||||
|
};
|
||||||
|
|
||||||
void writecurpath(const char *in){
|
void writecurpath(const char *in){
|
||||||
if (currentpath != NULL)
|
if (currentpath != NULL)
|
||||||
free(currentpath);
|
free(currentpath);
|
||||||
|
@ -289,7 +296,7 @@ int readfolder(const char *path){
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
int folderamount = 0, res;
|
int folderamount = 0, res;
|
||||||
|
|
||||||
if (res = f_opendir(&dir, path)){
|
if ((res = f_opendir(&dir, path))){
|
||||||
char errmes[50] = "";
|
char errmes[50] = "";
|
||||||
sprintf(errmes, "Error during f_opendir: %d", res);
|
sprintf(errmes, "Error during f_opendir: %d", res);
|
||||||
message(errmes, COLOR_RED);
|
message(errmes, COLOR_RED);
|
||||||
|
@ -317,9 +324,107 @@ int delfile(const char *path, const char *filename){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void filemenu(const char *startpath){
|
int del_recursive(char *path){
|
||||||
|
DIR dir;
|
||||||
|
FILINFO fno;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if ((res = f_opendir(&dir, path))){
|
||||||
|
char errmes[50] = "";
|
||||||
|
sprintf(errmes, "Error during f_opendir: %d", res);
|
||||||
|
message(errmes, COLOR_RED);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
||||||
|
/*
|
||||||
|
if (fno.fattrib & AM_DIR)
|
||||||
|
if ((res = del_recursive(getnextloc(path, fno.fname))))
|
||||||
|
return res;
|
||||||
|
*/
|
||||||
|
if (fno.fattrib & AM_DIR)
|
||||||
|
del_recursive(getnextloc(path, fno.fname));
|
||||||
|
|
||||||
|
else if ((res = f_unlink(getnextloc(path, fno.fname))))
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
f_closedir(&dir);
|
||||||
|
|
||||||
|
if ((res = f_unlink(path))){
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int filemenu(fs_entry file){
|
||||||
|
int temp;
|
||||||
|
strlcpy(explfilemenu[1].name, file.name, 43);
|
||||||
|
|
||||||
|
for (temp = 4; temp < 8; temp++)
|
||||||
|
if ((file.property & (1 << temp)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
sprintf(explfilemenu[2].name, "\nSize: %d %s", file.size, sizevalues[temp - 4]);
|
||||||
|
|
||||||
|
if (strstr(file.name, ".bin") != NULL && file.size & ISKB){
|
||||||
|
explfilemenu[7].property = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
explfilemenu[7].property = -1;
|
||||||
|
|
||||||
|
temp = makemenu(explfilemenu, 9);
|
||||||
|
|
||||||
|
switch (temp){
|
||||||
|
case COPY:
|
||||||
|
writeclipboard(getnextloc(currentpath, file.name), false, false);
|
||||||
|
break;
|
||||||
|
case MOVE:
|
||||||
|
writeclipboard(getnextloc(currentpath, file.name), true, false);
|
||||||
|
break;
|
||||||
|
case DELETE:
|
||||||
|
if ((temp = delfile(getnextloc(currentpath, file.name), file.name)) != -1)
|
||||||
|
return temp + 1;
|
||||||
|
case PAYLOAD:
|
||||||
|
launch_payload(getnextloc(currentpath, file.name));
|
||||||
|
break;
|
||||||
|
case HEXVIEW:
|
||||||
|
viewbytes(getnextloc(currentpath, file.name));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int foldermenu(){
|
||||||
|
int res;
|
||||||
|
char temp[50] = "";
|
||||||
|
|
||||||
|
res = makemenu(explfoldermenu, 4);
|
||||||
|
|
||||||
|
switch (res){
|
||||||
|
case EXITFOLDER:
|
||||||
|
return -1;
|
||||||
|
case DELETEFOLDER:
|
||||||
|
if (makewaitmenu("Do you want to delete this folder?\nThe entire folder, with all subcontents\n will be deleted!!!\n\nPress vol+/- to cancel\n", "Press power to contine...", 7)){
|
||||||
|
clearscreen();
|
||||||
|
gfx_printf("\nDeleting folder, please wait...");
|
||||||
|
if ((res = del_recursive(currentpath))){
|
||||||
|
sprintf(temp, "Error during del_recursive()! %d", res);
|
||||||
|
message(temp, COLOR_RED);
|
||||||
|
}
|
||||||
|
writecurpath(getprevloc(currentpath));
|
||||||
|
return readfolder(currentpath) + 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fileexplorer(const char *startpath){
|
||||||
int amount, res, tempint;
|
int amount, res, tempint;
|
||||||
char temp[100];
|
bool breakfree = false;
|
||||||
|
|
||||||
if (!strcmp(rootpath, "emmc:/") && !strcmp(startpath, "emmc:/"))
|
if (!strcmp(rootpath, "emmc:/") && !strcmp(startpath, "emmc:/"))
|
||||||
clipboardhelper = 0;
|
clipboardhelper = 0;
|
||||||
|
@ -336,21 +441,33 @@ void filemenu(const char *startpath){
|
||||||
while (1){
|
while (1){
|
||||||
res = makefilemenu(fileobjects, amount, currentpath);
|
res = makefilemenu(fileobjects, amount, currentpath);
|
||||||
if (res < 1){
|
if (res < 1){
|
||||||
if (res == -2){
|
switch (res){
|
||||||
if (!strcmp(rootpath, currentpath))
|
case -2:
|
||||||
|
if (!strcmp(rootpath, currentpath))
|
||||||
|
breakfree = true;
|
||||||
|
else {
|
||||||
|
writecurpath(getprevloc(currentpath));
|
||||||
|
amount = readfolder(currentpath);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
else {
|
|
||||||
writecurpath(getprevloc(currentpath));
|
|
||||||
amount = readfolder(currentpath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res == -1){
|
|
||||||
copyfile(clipboard, currentpath);
|
|
||||||
amount = readfolder(currentpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res == 0)
|
case -1:
|
||||||
break;
|
copyfile(clipboard, currentpath);
|
||||||
|
amount = readfolder(currentpath);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
tempint = foldermenu();
|
||||||
|
|
||||||
|
if (tempint < 0)
|
||||||
|
breakfree = true;
|
||||||
|
if (tempint > 0)
|
||||||
|
amount = tempint - 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (fileobjects[res - 1].property & ISDIR){
|
if (fileobjects[res - 1].property & ISDIR){
|
||||||
|
@ -358,42 +475,12 @@ void filemenu(const char *startpath){
|
||||||
amount = readfolder(currentpath);
|
amount = readfolder(currentpath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strlcpy(explfilemenu[1].name, fileobjects[res - 1].name, 43);
|
if ((tempint = filemenu(fileobjects[res - 1])))
|
||||||
|
amount = tempint - 1;
|
||||||
for (tempint = 4; tempint < 8; tempint++)
|
|
||||||
if ((fileobjects[res - 1].property & (1 << tempint)))
|
|
||||||
break;
|
|
||||||
|
|
||||||
sprintf(temp, "\nSize: %d %s", fileobjects[res - 1].size, sizevalues[tempint - 4]);
|
|
||||||
strcpy(explfilemenu[2].name, temp);
|
|
||||||
|
|
||||||
if (strstr(fileobjects[res - 1].name, ".bin") != NULL && fileobjects[res - 1].size & ISKB){
|
|
||||||
explfilemenu[7].property = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
explfilemenu[7].property = -1;
|
|
||||||
|
|
||||||
tempint = makemenu(explfilemenu, 9);
|
|
||||||
|
|
||||||
switch (tempint){
|
|
||||||
case COPY:
|
|
||||||
writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), false, false);
|
|
||||||
break;
|
|
||||||
case MOVE:
|
|
||||||
writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), true, false);
|
|
||||||
break;
|
|
||||||
case DELETE:
|
|
||||||
if ((tempint = delfile(getnextloc(currentpath, fileobjects[res - 1].name), fileobjects[res - 1].name)) != -1)
|
|
||||||
amount = tempint;
|
|
||||||
break;
|
|
||||||
case PAYLOAD:
|
|
||||||
launch_payload(getnextloc(currentpath, fileobjects[res - 1].name));
|
|
||||||
break;
|
|
||||||
case HEXVIEW:
|
|
||||||
viewbytes(getnextloc(currentpath, fileobjects[res - 1].name));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (breakfree)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,8 +37,13 @@ enum filemenuoptions {
|
||||||
HEXVIEW
|
HEXVIEW
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum foldermenuoptions {
|
||||||
|
EXITFOLDER = 1,
|
||||||
|
DELETEFOLDER
|
||||||
|
};
|
||||||
|
|
||||||
int readfolder(const char *path);
|
int readfolder(const char *path);
|
||||||
void filemenu();
|
void fileexplorer(const char *startpath);
|
||||||
bool checkfile(char* path);
|
bool checkfile(char* path);
|
||||||
u64 getfilesize(char *path);
|
u64 getfilesize(char *path);
|
||||||
int copy(const char *locin, const char *locout, bool print);
|
int copy(const char *locin, const char *locout, bool print);
|
|
@ -12,7 +12,7 @@
|
||||||
const char fixedoptions[3][50] = {
|
const char fixedoptions[3][50] = {
|
||||||
"Folder -> previous folder ",
|
"Folder -> previous folder ",
|
||||||
"Clipboard -> Current folder ",
|
"Clipboard -> Current folder ",
|
||||||
"Return to main menu "
|
"Current folder menu "
|
||||||
};
|
};
|
||||||
|
|
||||||
const char sizevalues[4][3] = {
|
const char sizevalues[4][3] = {
|
||||||
|
|
|
@ -98,7 +98,7 @@ void te_main(){
|
||||||
|
|
||||||
switch(res){
|
switch(res){
|
||||||
case SD_CARD:
|
case SD_CARD:
|
||||||
filemenu("SD:/");
|
fileexplorer("SD:/");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMMC_SAF:
|
case EMMC_SAF:
|
||||||
|
@ -107,7 +107,7 @@ void te_main(){
|
||||||
|
|
||||||
if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)){
|
if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)){
|
||||||
if (!mount_emmc(emmc_entries[res - 2], res - 1)){
|
if (!mount_emmc(emmc_entries[res - 2], res - 1)){
|
||||||
filemenu("emmc:/");
|
fileexplorer("emmc:/");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
message("EMMC failed to mount!", COLOR_RED);
|
message("EMMC failed to mount!", COLOR_RED);
|
||||||
|
|
Loading…
Reference in a new issue