BloombergLP::bdls::FilesystemUtil::findMatchingPaths

Load into the specified result vector all paths in the filesystem matching the specified pattern. The '*' character will match any number of characters in a filename; however, this matching will not span a directory separator (e.g., "logs/m*.txt" will not match "logs/march/001.txt"). '?' will match any one character. '*' and '?' may be used any number of times in the pattern. The special directories "." and ".." will not be matched against any pattern. Note that any initial contents of result will be erased, and that the paths in result will not be in any particular guaranteed order. Return the number of paths matched on success, and a negative value otherwise; if a negative value is returned, the contents of *result are undefined. The parameterized STRING_TYPE must be one of bsl::string, std::string, std::pmr::string (if supported), bsl::string_view, or bslstl::StringRef.

Synopsis

Declared in <bdls_filesystemutil.h>

static
int
findMatchingPaths(
    bsl::vector<bsl::string>* result,
    char const* pattern);

Description

WINDOWS-SPECIFIC NOTE: To support DOS idioms, the OS-provided search function has behavior that we have chosen not to work around: an extension consisting of wild-card characters ('?', '*') can match an extension or no extension. E.g., "file.?" matches "file.z", but not "file.txt"; however, it also matches "file" (without any extension). Likewise, "." matches any filename, including filenames having no extension. Also, on Windows (but not on Unix) attempting to match a pattern that is invalid UTF-8 will result in an error.

IBM-SPECIFIC WARNING: This function is not thread-safe. The AIX implementation of the system glob function can temporarily change the working directory of the entire program, casuing attempts in other threads to open files with relative path names to fail.