mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Scripting: fix 'dirsel' command
This commit is contained in:
parent
7befb8f1b5
commit
ddf6e11459
@ -824,20 +824,22 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) {
|
||||
|
||||
char path[_VAR_CNT_LEN];
|
||||
strncpy(path, argv[1], _VAR_CNT_LEN);
|
||||
char* npattern = strrchr(path, '/');
|
||||
if (strncmp(path, "Z:", 2) == 0) {
|
||||
ret = false;
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "forbidden drive");
|
||||
} else if (!npattern) {
|
||||
ret = false;
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "invalid path");
|
||||
} else if (id == CMD_ID_FILESEL) {
|
||||
u32 flags_ext = (flags & _FLG('d')) ? 0 : NO_DIRS;
|
||||
*(npattern++) = '\0';
|
||||
ret = FileSelector(choice, argv[0], path, npattern, flags_ext);
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "fileselect abort");
|
||||
char* npattern = strrchr(path, '/');
|
||||
if (!npattern) {
|
||||
ret = false;
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "invalid path");
|
||||
} else {
|
||||
u32 flags_ext = (flags & _FLG('d')) ? 0 : NO_DIRS;
|
||||
*(npattern++) = '\0';
|
||||
ret = FileSelector(choice, argv[0], path, npattern, flags_ext);
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "fileselect abort");
|
||||
}
|
||||
} else {
|
||||
ret = FileSelector(choice, argv[0], path, npattern, NO_FILES | SELECT_DIRS);
|
||||
ret = FileSelector(choice, argv[0], path, NULL, NO_FILES | SELECT_DIRS);
|
||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "dirselect abort");
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,8 @@ filesel "Please select a file" 0:/*.* SELFILE
|
||||
|
||||
# 'dirsel' COMMAND
|
||||
# The 'dirsel' command works identically to the 'filesel' command, but allows selecting a dir
|
||||
# Note that a final slash ('/') and no wildcard pattern is expected here.
|
||||
dirsel "Now, select a dir" 0:/ SELDIR
|
||||
# Note that a final slash ('/') is not expected here and there can be no wildcard pattern.
|
||||
dirsel "Now, select a dir" 0: SELDIR
|
||||
echo "You selected $[SELFILE]\nand $[SELDIR]\nWe'll do nothing with either :)."
|
||||
|
||||
# 'allow' COMMAND
|
||||
|
Loading…
x
Reference in New Issue
Block a user