Scripting: allow browsing dirs in filesel

This commit is contained in:
d0k3 2018-01-02 01:02:09 +01:00
parent 0dd72ceb27
commit c7d60879ae
2 changed files with 5 additions and 3 deletions

View File

@ -105,6 +105,7 @@ echo $[TESTREP]
# 'filesel' COMMAND # 'filesel' COMMAND
# The 'filesel' command allows the user to choose a file inside a directory # The 'filesel' command allows the user to choose a file inside a directory
# The path is stored inside a variable, and the selection can be limited via wildcards # The path is stored inside a variable, and the selection can be limited via wildcards
# -d / --include_dirs allows to browse folders and select files inside
filesel "Please select a file" 0:/*.* SELFILE filesel "Please select a file" 0:/*.* SELFILE
echo "You selected $[SELFILE]\nWe'll do nothing with that :)." echo "You selected $[SELFILE]\nWe'll do nothing with that :)."
@ -113,7 +114,7 @@ echo "You selected $[SELFILE]\nWe'll do nothing with that :)."
# doing this from the beginning is preferable, so that no actions are taken unless all required write permissions are unlocked # doing this from the beginning is preferable, so that no actions are taken unless all required write permissions are unlocked
# (note #1: without 'allow', write permissions are still in place and the user will be asked on demand) # (note #1: without 'allow', write permissions are still in place and the user will be asked on demand)
# (note #2: this simple testing script requires no additional permissions, thus the command is hidden behind a '#') # (note #2: this simple testing script requires no additional permissions, thus the command is hidden behind a '#')
# -a / -all allows writes to the specified location and all included files and directories # -a / --all allows writes to the specified location and all included files and directories
# allow -a M:/ # allow -a M:/
# 'rm' COMMAND # 'rm' COMMAND

View File

@ -124,7 +124,7 @@ Gm9ScriptCmd cmd_list[] = {
{ CMD_ID_QR , "qr" , 2, 0 }, { CMD_ID_QR , "qr" , 2, 0 },
{ CMD_ID_ASK , "ask" , 1, 0 }, { CMD_ID_ASK , "ask" , 1, 0 },
{ CMD_ID_INPUT , "input" , 2, 0 }, { CMD_ID_INPUT , "input" , 2, 0 },
{ CMD_ID_FILESEL , "filesel" , 3, 0 }, { CMD_ID_FILESEL , "filesel" , 3, _FLG('d') },
{ CMD_ID_SET , "set" , 2, 0 }, { CMD_ID_SET , "set" , 2, 0 },
{ CMD_ID_STRSPLIT, "strsplit", 3, _FLG('b') | _FLG('f')}, { CMD_ID_STRSPLIT, "strsplit", 3, _FLG('b') | _FLG('f')},
{ CMD_ID_STRREP , "strrep" , 3, 0 }, { CMD_ID_STRREP , "strrep" , 3, 0 },
@ -471,6 +471,7 @@ u32 get_flag(char* str, u32 len, char* err_str) {
else if (len == 2) flag_char = str[1]; else if (len == 2) flag_char = str[1];
else if (strncmp(str, "--all", len) == 0) flag_char = 'a'; else if (strncmp(str, "--all", len) == 0) flag_char = 'a';
else if (strncmp(str, "--before", len) == 0) flag_char = 'b'; else if (strncmp(str, "--before", len) == 0) flag_char = 'b';
else if (strncmp(str, "--include_dirs", len) == 0) flag_char = 'd';
else if (strncmp(str, "--first", len) == 0) flag_char = 'f'; else if (strncmp(str, "--first", len) == 0) flag_char = 'f';
else if (strncmp(str, "--hash", len) == 0) flag_char = 'h'; else if (strncmp(str, "--hash", len) == 0) flag_char = 'h';
else if (strncmp(str, "--skip", len) == 0) flag_char = 'k'; else if (strncmp(str, "--skip", len) == 0) flag_char = 'k';
@ -816,7 +817,7 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) {
if (err_str) snprintf(err_str, _ERR_STR_LEN, "invalid path"); if (err_str) snprintf(err_str, _ERR_STR_LEN, "invalid path");
} else { } else {
*(npattern++) = '\0'; *(npattern++) = '\0';
ret = FileSelector(choice, argv[0], path, npattern, false, true); ret = FileSelector(choice, argv[0], path, npattern, false, !(flags & _FLG('d')));
if (err_str) snprintf(err_str, _ERR_STR_LEN, "fileselect abort"); if (err_str) snprintf(err_str, _ERR_STR_LEN, "fileselect abort");
} }