mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Scripting: improve handling for input, find & findnot
This commit is contained in:
parent
de230fd8e5
commit
34e5b23c80
@ -174,7 +174,7 @@ void SearchDirContents(DirStruct* contents, const char* path, const char* patter
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GetDirContents(DirStruct* contents, const char* path) {
|
void GetDirContents(DirStruct* contents, const char* path) {
|
||||||
if (*search_path && DriveType(path) & DRV_SEARCH) {
|
if (*search_path && (DriveType(path) & DRV_SEARCH)) {
|
||||||
ShowString("Searching, please wait...");
|
ShowString("Searching, please wait...");
|
||||||
SearchDirContents(contents, search_path, search_pattern, true);
|
SearchDirContents(contents, search_path, search_pattern, true);
|
||||||
if (search_title_mode) SetDirGoodNames(contents);
|
if (search_title_mode) SetDirGoodNames(contents);
|
||||||
|
@ -378,10 +378,16 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) {
|
|||||||
ret = ShowPrompt(true, argv[0]);
|
ret = ShowPrompt(true, argv[0]);
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "user abort");
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "user abort");
|
||||||
} else if (id == CMD_ID_INPUT) {
|
} else if (id == CMD_ID_INPUT) {
|
||||||
|
char input[_VAR_CNT_LEN] = { 0 };
|
||||||
char* var = get_var(argv[1], NULL);
|
char* var = get_var(argv[1], NULL);
|
||||||
if (!*var) set_var(argv[1], ""); // make sure the var exists
|
strncpy(input, var, _VAR_CNT_LEN);
|
||||||
ret = ShowStringPrompt(var, _VAR_CNT_LEN, argv[0]);
|
ret = ShowStringPrompt(input, _VAR_CNT_LEN, argv[0]);
|
||||||
|
if (ret) set_var(argv[1], "");
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "user abort");
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "user abort");
|
||||||
|
if (ret) {
|
||||||
|
ret = set_var(argv[1], input);
|
||||||
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "var fail");
|
||||||
|
}
|
||||||
} else if (id == CMD_ID_SET) {
|
} else if (id == CMD_ID_SET) {
|
||||||
ret = set_var(argv[0], argv[1]);
|
ret = set_var(argv[0], argv[1]);
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "set fail");
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "set fail");
|
||||||
@ -432,22 +438,20 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) {
|
|||||||
} else if (id == CMD_ID_UMOUNT) {
|
} else if (id == CMD_ID_UMOUNT) {
|
||||||
InitImgFS(NULL);
|
InitImgFS(NULL);
|
||||||
} else if (id == CMD_ID_FIND) {
|
} else if (id == CMD_ID_FIND) {
|
||||||
char* path = set_var(argv[1], ""); // setup the variable, get pointer
|
char path[_VAR_CNT_LEN];
|
||||||
if (!path) {
|
ret = (fvx_findpath(path, argv[0]) == FR_OK);
|
||||||
ret = false;
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "find fail");
|
||||||
|
if (ret) {
|
||||||
|
ret = set_var(argv[1], path);
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "var fail");
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "var fail");
|
||||||
} else {
|
|
||||||
ret = (fvx_findpath(path, argv[0]) == FR_OK);
|
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "find fail");
|
|
||||||
}
|
}
|
||||||
} else if (id == CMD_ID_FINDNOT) {
|
} else if (id == CMD_ID_FINDNOT) {
|
||||||
char* path = set_var(argv[1], ""); // setup the variable, get pointer
|
char path[_VAR_CNT_LEN];
|
||||||
if (!path) {
|
ret = (fvx_findnopath(path, argv[0]) == FR_OK);
|
||||||
ret = false;
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "findnot fail");
|
||||||
|
if (ret) {
|
||||||
|
ret = set_var(argv[1], path);
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "var fail");
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "var fail");
|
||||||
} else {
|
|
||||||
ret = (fvx_findnopath(path, argv[0]) == FR_OK);
|
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "findnot fail");
|
|
||||||
}
|
}
|
||||||
} else if (id == CMD_ID_SHA) {
|
} else if (id == CMD_ID_SHA) {
|
||||||
u8 sha256_fil[0x20];
|
u8 sha256_fil[0x20];
|
||||||
|
@ -347,7 +347,7 @@ FRESULT fvx_findnopath (TCHAR* path, const TCHAR* pattern) {
|
|||||||
}
|
}
|
||||||
if (n_rep >= 16) return FR_DENIED;
|
if (n_rep >= 16) return FR_DENIED;
|
||||||
}
|
}
|
||||||
if (!n_rep) return fvx_stat(path, NULL);
|
if (!n_rep) return (fvx_stat(path, NULL) == FR_OK) ? FR_NO_PATH : FR_OK;
|
||||||
|
|
||||||
while (fvx_stat(path, NULL) == FR_OK) {
|
while (fvx_stat(path, NULL) == FR_OK) {
|
||||||
for (INT i = n_rep - 1; (i >= 0); i--) {
|
for (INT i = n_rep - 1; (i >= 0); i--) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user