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

add more functions

This commit is contained in:
Such Meme, Many Skill 2020-04-01 13:57:25 +02:00
parent 0e60746179
commit f438827263
4 changed files with 75 additions and 8 deletions

View file

@ -167,6 +167,7 @@ int filemenu(menu_entry file){
case FILE_SCRIPT:
//ParseScript(fsutil_getnextloc(currentpath, file.name));
tester(fsutil_getnextloc(currentpath, file.name));
fsreader_readfolder(currentpath);
break;
case FILE_HEXVIEW:
viewbytes(fsutil_getnextloc(currentpath, file.name));

View file

@ -63,8 +63,10 @@ int parseStringInput(char *in, char **out){
u32 currentcolor = COLOR_WHITE;
int part_printf(){
char *toprint;
if (parseStringInput(argv[0], &toprint))
return -1;
SWAPCOLOR(currentcolor);
parseStringInput(argv[0], &toprint);
gfx_printf(toprint);
gfx_printf("\n");
return 0;
@ -74,6 +76,8 @@ int part_print_int(){
int toprint;
if (parseIntInput(argv[0], &toprint))
return -1;
SWAPCOLOR(currentcolor);
gfx_printf("%s: %d\n", argv[0], toprint);
return 0;
}
@ -363,9 +367,71 @@ int part_fs_MakeDir(){
return res;
}
DIR dir;
FILINFO fno;
int isdirvalid = false;
int part_fs_OpenDir(){
char *path;
if (parseStringInput(argv[0], &path))
return -1;
if (f_opendir(&dir, path))
return -1;
isdirvalid = true;
str_int_add("@ISDIRVALID", isdirvalid);
return 0;
}
int part_fs_CloseDir(){
if (!isdirvalid)
return 0;
f_closedir(&dir);
isdirvalid = false;
str_int_add("@ISDIRVALID", isdirvalid);
return 0;
}
int part_fs_ReadDir(){
if (!isdirvalid)
return -1;
if (!f_readdir(&dir, &fno) && fno.fname[0]){
str_str_add("$FSOBJNAME", fno.fname);
str_int_add("@ISDIR", (fno.fattrib & AM_DIR) ? 1 : 0);
}
else {
part_fs_CloseDir();
}
return 0;
}
int part_setPrintPos(){
int left, right;
if (parseIntInput(argv[0], &left))
return -1;
if (parseIntInput(argv[1], &right))
return -1;
if (left > 42)
return -1;
if (right > 78)
return -1;
gfx_con_setpos(left * 16, right * 16);
return 0;
}
str_fnc_struct functions[] = {
{"printf", part_printf, 1},
{"printInt", part_print_int, 1},
{"setPrintPos", part_setPrintPos, 2},
{"if", part_if, 1},
{"math", part_Math, 3},
{"check", part_Check, 3},
@ -383,6 +449,9 @@ str_fnc_struct functions[] = {
{"fs_delRecursive", part_fs_DeleteRecursive, 1},
{"fs_copy", part_fs_Copy, 2},
{"fs_copyRecursive", part_fs_CopyRecursive, 2},
{"fs_openDir", part_fs_OpenDir, 1},
{"fs_closeDir", part_fs_CloseDir, 0},
{"fs_readDir", part_fs_ReadDir, 0},
{"mmc_connect", part_ConnectMMC, 1},
{"mmc_mount", part_MountMMC, 1},
{"pause", part_Pause, 0},

View file

@ -14,6 +14,7 @@
#include "../fs/fsactions.h"
#include "functions.h"
#include "variables.h"
#include "../fs/fsreader.h"
u32 countchars(char* in, char target) {
@ -133,8 +134,6 @@ char *readtilchar(char end, char ignore){
char *funcbuff = NULL;
void functionparser(){
char *unsplitargs;
FSIZE_t fileoffset;
u32 argsize = 0;
/*
if (funcbuff != NULL)
@ -162,8 +161,6 @@ void functionparser(){
char *gettargetvar(){
char *variable = NULL;
FSIZE_t fileoffset;
u32 varsize = 0;
variable = readtilchar('=', ' ');
@ -176,8 +173,6 @@ char *gettargetvar(){
void mainparser(){
char *variable = NULL;
int res, out = 0;
FSIZE_t fileoffset;
u32 varsize = 0;
getnextvalidchar();
@ -257,6 +252,7 @@ void skipbrackets(){
}
extern u32 currentcolor;
extern char *currentpath;
void tester(char *path){
int res;
forceExit = false;
@ -278,6 +274,7 @@ void tester(char *path){
str_int_add("@BTN_POWER", 0);
str_int_add("@BTN_VOL+", 0);
str_int_add("@BTN_VOL-", 0);
str_str_add("$CURRENTPATH", currentpath);
//str_int_printall();

View file

@ -221,7 +221,7 @@ int str_str_index(int index, char **out){
dict_str_str *temp;
temp = str_str_table;
for (int i = 0; i < (index - 1); i++){
for (int i = 0; i < index; i++){
if (temp == NULL)
return -1;
temp = temp->next;