From a2f88815bf1baec937006a960f07397162cc87e6 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 10 Jun 2017 19:03:58 +0200 Subject: [PATCH] implement ? wildcard --- ostd/filesystem.hh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ostd/filesystem.hh b/ostd/filesystem.hh index cfb1837..098254e 100644 --- a/ostd/filesystem.hh +++ b/ostd/filesystem.hh @@ -122,12 +122,18 @@ namespace detail { if (!*wname || (*wname == '*')) { break; } + /* ? wildcard matches any character */ + if ((*wname == '?') && *fname) { + ++wname; + ++fname; + continue; + } if (*fname++ != *wname++) { return false; } } } - /* skip wildcards; a wildcard matches 0 or more */ + /* skip * wildcards; a wildcard matches 0 or more */ if (*wname == '*') { while (*wname == '*') { ++wname; @@ -199,8 +205,8 @@ namespace detail { } return; } - /* a regular * wildcard */ - if (c == '*') { + /* a regular * or ? wildcard */ + if ((c == '*') || (c == '?')) { ++beg; filesystem::directory_iterator it{ip}; for (auto &de: it) {