diff --git a/HelloScript.gm9 b/HelloScript.gm9 index ea76a9d..837018f 100644 --- a/HelloScript.gm9 +++ b/HelloScript.gm9 @@ -105,6 +105,7 @@ echo $[TESTREP] # 'filesel' COMMAND # 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 +# -d / --include_dirs allows to browse folders and select files inside filesel "Please select a file" 0:/*.* SELFILE 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 # (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 '#') -# -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:/ # 'rm' COMMAND diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index c2da62e..1d8ebe1 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -124,7 +124,7 @@ Gm9ScriptCmd cmd_list[] = { { CMD_ID_QR , "qr" , 2, 0 }, { CMD_ID_ASK , "ask" , 1, 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_STRSPLIT, "strsplit", 3, _FLG('b') | _FLG('f')}, { 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 (strncmp(str, "--all", len) == 0) flag_char = 'a'; 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, "--hash", len) == 0) flag_char = 'h'; 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"); } else { *(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"); }