1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-26 13:52:06 +00:00

File sizes shown in list screen

This commit is contained in:
Such Meme, Many Skill 2019-08-16 21:40:04 +02:00
parent 5b15e4cdf7
commit 45eb25270f
5 changed files with 59 additions and 12 deletions

View file

@ -217,7 +217,7 @@ void gfx_putc(char c)
} }
} }
gfx_con.x += 16; gfx_con.x += 16;
if (gfx_con.x >= gfx_ctxt.width - 16) { if (gfx_con.x >= gfx_ctxt.width - 8) {
gfx_con.x = 0; gfx_con.x = 0;
gfx_con.y += 16; gfx_con.y += 16;
} }

View file

@ -56,7 +56,7 @@ void meme_clearscreen(){
gfx_printf("%k%pTegraExplorer, by SuchMemeManySkill\n%k%p", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT); gfx_printf("%k%pTegraExplorer, by SuchMemeManySkill\n%k%p", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT);
} }
void _printwithhighlight(int offset, int folderamount, char *items[], int highlight, unsigned int *muhbits){ void _printwithhighlight(int offset, int folderamount, char *items[], int highlight, unsigned int *muhbits, const char path[]){
char temp[39]; char temp[39];
int i = 0; int i = 0;
int ret = 0; int ret = 0;
@ -73,9 +73,16 @@ void _printwithhighlight(int offset, int folderamount, char *items[], int highli
ret = ret - 1; ret = ret - 1;
} }
gfx_con.x = 720 - (16 * 6); gfx_con.x = 720 - (16 * 7);
if (muhbits[i + offset] & OPTION1) gfx_printf("DIR"); if (!(muhbits[i + offset] & OPTION1)) { //should change later
else gfx_printf("FILE"); char temp[6];
char temppath[PATHSIZE];
strcpy(temppath, path);
strcat(temppath, "/");
strcat(temppath, items[i + offset]);
return_readable_byte_amounts(getfilesize(temppath), temp);
gfx_printf("%s", temp);
}
i++; i++;
} }
} }
@ -91,7 +98,7 @@ int fileexplorergui(char *items[], unsigned int *muhbits, const char path[], int
gfx_printf("%k%s\n%k", COLOR_GREEN, temp, COLOR_WHITE); gfx_printf("%k%s\n%k", COLOR_GREEN, temp, COLOR_WHITE);
while(1){ while(1){
if (change){ if (change){
_printwithhighlight(offset, folderamount, items, select, muhbits); _printwithhighlight(offset, folderamount, items, select, muhbits, path);
change = false; change = false;
msleep(sleepvalue); msleep(sleepvalue);
} }

View file

@ -23,8 +23,11 @@ int _openfilemenu(const char *path, char *clipboardpath){
addchartoarray("Delete file", options, 3); addchartoarray("Delete file", options, 3);
gfx_printf("%kPath: %s%k\n\n", COLOR_GREEN, path, COLOR_WHITE); gfx_printf("%kPath: %s%k\n\n", COLOR_GREEN, path, COLOR_WHITE);
int temp = (fno.fsize / 1024 / 1024);
gfx_printf("Size MB: %d", temp); char size[6];
return_readable_byte_amounts(fno.fsize, size);
gfx_printf("Size: %s", size);
res = gfx_menulist(160, options, 4); res = gfx_menulist(160, options, 4);
switch(res){ switch(res){
@ -52,8 +55,8 @@ void sdexplorer(char *items[], unsigned int *muhbits){
int value = 1; int value = 1;
int copymode = -1; int copymode = -1;
int folderamount = 0; int folderamount = 0;
char path[255] = "sd:/"; char path[PATHSIZE] = "sd:/";
char clipboard[255] = ""; char clipboard[PATHSIZE] = "";
int temp = -1; int temp = -1;
//static const u32 colors[8] = {COLOR_RED, COLOR_ORANGE, COLOR_YELLOW, COLOR_GREEN, COLOR_BLUE, COLOR_VIOLET, COLOR_DEFAULT, COLOR_WHITE}; //static const u32 colors[8] = {COLOR_RED, COLOR_ORANGE, COLOR_YELLOW, COLOR_GREEN, COLOR_BLUE, COLOR_VIOLET, COLOR_DEFAULT, COLOR_WHITE};
while(1){ while(1){

View file

@ -27,6 +27,39 @@ void addpartpath(char *path, char *add){
strcat(path, add); strcat(path, add);
} }
void return_readable_byte_amounts(int size, char *in){
char type[3];
int sizetemp = size;
int muhbytes = 0;
strcpy(type, "B");
while(sizetemp > 1024){
muhbytes++;
sizetemp = sizetemp / 1024;
}
switch(muhbytes){
case 0:
strcpy(type, "B");
break;
case 1:
strcpy(type, "KB");
break;
case 2:
strcpy(type, "MB");
break;
default:
strcpy(type, "GB");
break;
}
sprintf(in, "%d%s", sizetemp, type);
}
int getfilesize(const char *path){
FILINFO fno;
f_stat(path, &fno);
return fno.fsize;
}
void utils_waitforpower(){ void utils_waitforpower(){
u32 btn = btn_wait(); u32 btn = btn_wait();
if (btn & BTN_VOL_UP) if (btn & BTN_VOL_UP)
@ -118,7 +151,7 @@ int copy(const char *src, const char *dst){
int copywithpath(const char *src, const char *dstpath, int mode){ int copywithpath(const char *src, const char *dstpath, int mode){
FILINFO fno; FILINFO fno;
f_stat(src, &fno); f_stat(src, &fno);
char dst[255]; char dst[PATHSIZE];
strcpy(dst, dstpath); strcpy(dst, dstpath);
if (strcmp(dstpath, "sd:/") != 0) strcat(dst, "/"); if (strcmp(dstpath, "sd:/") != 0) strcat(dst, "/");
strcat(dst, fno.fname); strcat(dst, fno.fname);

View file

@ -5,6 +5,8 @@
#define OPTION3 (1 << 2) #define OPTION3 (1 << 2)
#define OPTION4 (1 << 3) #define OPTION4 (1 << 3)
#define PATHSIZE 512
void utils_gfx_init(); void utils_gfx_init();
void utils_waitforpower(); void utils_waitforpower();
void removepartpath(char *path); void removepartpath(char *path);
@ -13,3 +15,5 @@ int readfolder(char *items[], unsigned int *muhbits, const char *path);
int copy(const char *src, const char *dst); int copy(const char *src, const char *dst);
void addchartoarray(char *add, char *items[], int spot); void addchartoarray(char *add, char *items[], int spot);
int copywithpath(const char *src, const char *dstpath, int mode); int copywithpath(const char *src, const char *dstpath, int mode);
void return_readable_byte_amounts(int size, char *in);
int getfilesize(const char *path);