private static int PushGlobs(string cwd, IList<string> ary, GlobPattern pattern) { pattern.flags |= FNM_SYSCASE; return GlobHelper(cwd, pattern.path, pattern.begin, pattern.end, -1, pattern.flags, glob_caller, new GlobArgs(push_pattern, ary)); }
private static int PushBraces(string cwd, IList<string> result, GlobPattern pattern) { pattern.Reset(); int lbrace = pattern.IndexOf('{'); // index of left-most brace int rbrace = pattern.FindClosingIndexOf(lbrace);// index of right-most brace // No or mismatched braces..Move along..nothing to see here if(lbrace == -1 || rbrace == -1) return PushGlobs(cwd, result, pattern); // Peel onion...make subpatterns out of outer layer of glob and recall with each subpattern // Example: foo{a{c},b}bar -> fooa{c}bar, foobbar string buf = ""; int middleRegionIndex; int i = lbrace; while(pattern.path[i] != '}') { middleRegionIndex = i + 1; for(i = middleRegionIndex; i < pattern.end && pattern.path[i] != '}' && pattern.path[i] != ','; i++) { if (pattern.path[i] == '{') pattern.FindClosingIndexOf(i); // skip inner braces } buf = ""; buf += pattern.path.Substring(pattern.begin, lbrace - pattern.begin); buf += pattern.path.Substring(middleRegionIndex, i - middleRegionIndex); buf += pattern.path.Substring(rbrace+1, pattern.end - (rbrace+1)); int status = PushBraces(cwd, result, new GlobPattern(buf, 0, buf.Length, pattern.flags)); if(status != 0) return status; } return 0; // All braces pushed.. }