|
6 | 6 |
|
7 | 7 | namespace System.IO.Abstractions.TestingHelpers |
8 | 8 | { |
| 9 | + using XFS = MockUnixSupport; |
| 10 | + |
9 | 11 | [Serializable] |
10 | 12 | public class MockDirectory : DirectoryBase |
11 | 13 | { |
@@ -172,19 +174,21 @@ private string[] GetFilesInternal(IEnumerable<string> files, string path, string |
172 | 174 | path = EnsurePathEndsWithDirectorySeparator(path); |
173 | 175 | path = mockFileDataAccessor.Path.GetFullPath(path); |
174 | 176 |
|
175 | | - string allDirectoriesPattern = XFS.IsUnixPlatform() |
| 177 | + bool isUnix = XFS.IsUnixPlatform(); |
| 178 | + |
| 179 | + string allDirectoriesPattern = isUnix |
176 | 180 | ? @"([^<>:""/|?*]*/)*" |
177 | 181 | : @"([^<>:""/\\|?*]*\\)*"; |
178 | 182 |
|
179 | 183 | var fileNamePattern = searchPattern == "*" |
180 | | - ? XFS.IsUnixPlatform() ? @"[^/]*?/?" : @"[^\\]*?\\?" |
| 184 | + ? isUnix ? @"[^/]*?/?" : @"[^\\]*?\\?" |
181 | 185 | : Regex.Escape(searchPattern) |
182 | | - .Replace(@"\*", XFS.IsUnixPlatform() ? @"[^<>:""/|?*]*?" : @"[^<>:""/\\|?*]*?") |
183 | | - .Replace(@"\?", XFS.IsUnixPlatform() ? @"[^<>:""/|?*]?" : @"[^<>:""/\\|?*]?"); |
| 186 | + .Replace(@"\*", isUnix ? @"[^<>:""/|?*]*?" : @"[^<>:""/\\|?*]*?") |
| 187 | + .Replace(@"\?", isUnix ? @"[^<>:""/|?*]?" : @"[^<>:""/\\|?*]?"); |
184 | 188 |
|
185 | 189 | var pathPattern = string.Format( |
186 | 190 | CultureInfo.InvariantCulture, |
187 | | - XFS.IsUnixPlatform() ? @"(?i:^{0}{1}{2}(?:/?)$)" : @"(?i:^{0}{1}{2}(?:\\?)$)", |
| 191 | + isUnix ? @"(?i:^{0}{1}{2}(?:/?)$)" : @"(?i:^{0}{1}{2}(?:\\?)$)", |
188 | 192 | Regex.Escape(path), |
189 | 193 | searchOption == SearchOption.AllDirectories ? allDirectoriesPattern : string.Empty, |
190 | 194 | fileNamePattern); |
|
0 commit comments