From: bones_was_here Date: Tue, 13 Aug 2024 04:25:36 +0000 (+1000) Subject: con: support tab completed directory paths for: ls, dir X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d98ec82a83a8717ffde4c000426ab0b4dd2acf4;p=xonotic%2Fdarkplaces.git con: support tab completed directory paths for: ls, dir If the search pattern ends in / the directory contents are listed (as if the pattern had ended in /*). Signed-off-by: bones_was_here --- diff --git a/fs.c b/fs.c index 2ce128e8..8f6384aa 100644 --- a/fs.c +++ b/fs.c @@ -3977,6 +3977,18 @@ static int FS_ListDirectory(const char *pattern, int oneperline) const char *name; char linebuf[MAX_INPUTLINE]; fssearch_t *search; + + // if the directory path ends in '/' then list its contents + // so commands behave as expected and directory tab completion is convenient + l = strlen(pattern); + if (pattern[l - 1] == '/' && l < (int)sizeof(linebuf) - 1) + { + memcpy(linebuf, pattern, l); + linebuf[l] = '*'; + linebuf[l + 1] = '\0'; + pattern = linebuf; + } + search = FS_Search(pattern, true, true, NULL); if (!search) return 0;