1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.IO.Abstractions;
- namespace ArcToolkitCLI.Util
- {
- internal class Glob
- {
- public static readonly char[] GlobCharacters =
- {
- '*',
- '{',
- '}',
- '[',
- ']',
- '?'
- };
- public static IEnumerable<FileSystemInfoBase> EnumerateFiles(IEnumerable<string> patterns)
- {
- foreach (var pattern in patterns)
- if (IsGlob(pattern))
- foreach (var file in GlobExpressions.Glob.Files(Environment.CurrentDirectory, pattern))
- yield return new FileInfoWrapper(new FileSystem(), new FileInfo(file));
- else
- yield return new FileInfoWrapper(new FileSystem(), new FileInfo(pattern));
- }
- public static bool IsGlob(string path) { return path.IndexOfAny(GlobCharacters) >= 0; }
- }
- }
|