Skip to content

Commit

Permalink
Fix VFS.SubDirs VFS.RAW pattern matching
Browse files Browse the repository at this point in the history
Consider a folder setup like this:
```
 base_dir
 ├ xxa
 ├ xxb
 └ yyc
```
and you want to find subfolders starting with "xx",
so you do `VFS.SubDirs("base_dir", "xx*", VFS.RAW)`.

The issue was that for `VFS.RAW`, the pattern was applied twice:
once during the actual filesystem search, where it correctly worked
on the filename only, and then a second time where it was applied
to the whole path (e.g. "base_dir/xxa" and not just "xxa"), so if
the pattern didn't happen to also match the initial folders, nothing
would be returned (although, most people seem to put a "*" wildcard
as the pattern, so it wasn't so bad since it does match the path).

Remove the second search since it is both redundant and incorrect.
  • Loading branch information
sprunk committed Jul 22, 2023
1 parent 2f69b5f commit a700bc0
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions rts/System/FileSystem/FileHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,6 @@ bool CFileHandler::InsertRawDirs(
dirSet.reserve(dirSet.size() + found.size());

for (std::string& dir: found) {
if (!spring::regex_match(dir, regexpattern))
continue;

dirSet.emplace_back(std::move(dir));
}
#endif
Expand Down

0 comments on commit a700bc0

Please sign in to comment.