35void Glob::glob(
const std::string &pathPattern, std::set<std::string> &files,
int options) {
45 Poco::Glob::glob(pathPattern, files, Poco::Glob::GLOB_CASELESS);
47 Poco::Glob::glob(pathPattern, files, options);
52 const std::string STAR(
"*");
53 const std::string STAR_ESCAPED(
"\\*");
54 const std::string QUESTION(
"?");
55 const std::string QUESTION_ESCAPED(
"\\?");
57 const std::string REGEX_MATCH_GLOB(
".+");
58 const std::string REGEX_MATCH_CHAR(
".");
59 const std::string REGEX_START_STR(
"^");
60 const std::string REGEX_END_STR(
"$");
63 std::string output = globPattern;
66 std::string::size_type pos = 0;
67 while ((pos = output.find(STAR, pos)) != std::string::npos) {
68 if ((pos > 0) && (pos + 1 != std::string::npos)) {
69 if (output.substr(pos - 1, STAR_ESCAPED.length()) == STAR_ESCAPED) {
74 output.erase(pos, STAR.length());
75 output.insert(pos, REGEX_MATCH_GLOB);
76 pos += REGEX_MATCH_GLOB.length();
81 while ((pos = output.find(QUESTION, pos)) != std::string::npos) {
82 if ((pos > 0) && (pos + 1 != std::string::npos)) {
83 if (output.substr(pos - 1, QUESTION_ESCAPED.length()) == QUESTION_ESCAPED) {
88 output.erase(pos, QUESTION.length());
89 output.insert(pos, REGEX_MATCH_CHAR);
90 pos += REGEX_MATCH_CHAR.length();
95 while ((pos = output.find(
"[!", pos)) != std::string::npos) {
96 output.erase(pos, std::string(
"[!").length());
97 output.insert(pos,
"![");
98 pos += std::string(
"![").length();
102 return REGEX_START_STR + output + REGEX_END_STR;
static void glob(const std::string &pathPattern, std::set< std::string > &files, int options=0)
Creates a set of files that match the given pathPattern.