forked from Mirror/GodMode9
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];
|
char path[_VAR_CNT_LEN];
|
||||||
strncpy(path, argv[1], _VAR_CNT_LEN);
|
strncpy(path, argv[1], _VAR_CNT_LEN);
|
||||||
char* npattern = strrchr(path, '/');
|
|
||||||
if (strncmp(path, "Z:", 2) == 0) {
|
if (strncmp(path, "Z:", 2) == 0) {
|
||||||
ret = false;
|
ret = false;
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "forbidden drive");
|
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) {
|
} else if (id == CMD_ID_FILESEL) {
|
||||||
u32 flags_ext = (flags & _FLG('d')) ? 0 : NO_DIRS;
|
char* npattern = strrchr(path, '/');
|
||||||
*(npattern++) = '\0';
|
if (!npattern) {
|
||||||
ret = FileSelector(choice, argv[0], path, npattern, flags_ext);
|
ret = false;
|
||||||
if (err_str) snprintf(err_str, _ERR_STR_LEN, "fileselect abort");
|
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 {
|
} 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");
|
if (err_str) snprintf(err_str, _ERR_STR_LEN, "dirselect abort");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ filesel "Please select a file" 0:/*.* SELFILE
|
|||||||
|
|
||||||
# 'dirsel' COMMAND
|
# 'dirsel' COMMAND
|
||||||
# The 'dirsel' command works identically to the 'filesel' command, but allows selecting a dir
|
# 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.
|
# Note that a final slash ('/') is not expected here and there can be no wildcard pattern.
|
||||||
dirsel "Now, select a dir" 0:/ SELDIR
|
dirsel "Now, select a dir" 0: SELDIR
|
||||||
echo "You selected $[SELFILE]\nand $[SELDIR]\nWe'll do nothing with either :)."
|
echo "You selected $[SELFILE]\nand $[SELDIR]\nWe'll do nothing with either :)."
|
||||||
|
|
||||||
# 'allow' COMMAND
|
# 'allow' COMMAND
|
||||||
|
Loading…
x
Reference in New Issue
Block a user