From 8d98ec82a83a8717ffde4c000426ab0b4dd2acf4 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 13 Aug 2024 14:25:36 +1000 Subject: [PATCH] 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 --- fs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; -- 2.39.2