/* * Method: GetFileSystemEntries * * Simulate Directories.GetFileSystemEntries where file names are short. * */ private static string[] GetFileSystemEntries(FileMatcher.FileSystemEntity entityType, string path, string pattern, string projectDirectory, bool stripProjectDirectory) { if ( pattern == @"LONGDI~1" && (@"D:\" == path || @"\\server\share\" == path || path.Length == 0) ) { return new string[] { Path.Combine(path, "LongDirectoryName") }; } else if ( pattern == @"LONGSU~1" && (@"D:\LongDirectoryName" == path || @"\\server\share\LongDirectoryName" == path || @"LongDirectoryName" == path) ) { return new string[] { Path.Combine(path, "LongSubDirectory") }; } else if ( pattern == @"LONGFI~1.TXT" && (@"D:\LongDirectoryName\LongSubDirectory" == path || @"\\server\share\LongDirectoryName\LongSubDirectory" == path || @"LongDirectoryName\LongSubDirectory" == path) ) { return new string[] { Path.Combine(path, "LongFileName.txt") }; } else if ( pattern == @"pomegr~1" && @"c:\apple\banana\tomato" == path ) { return new string[] { Path.Combine(path, "pomegranate") }; } else if ( @"c:\apple\banana\tomato\pomegranate\orange" == path ) { // No files exist here. This is an empty directory. return new string[0]; } else { Console.WriteLine("GetFileSystemEntries('{0}', '{1}')", path, pattern); Assert.True(false, "Unexpected input into GetFileSystemEntries"); } return new string[] { "<undefined>" }; }
/// <summary> /// Method that is delegable for use by FileMatcher. This method simulates a filesystem by returning /// files and\or folders that match the requested path and pattern. /// </summary> /// <param name="entityType">Files, Directories or both</param> /// <param name="path">The path to search.</param> /// <param name="pattern">The pattern to search (may be null)</param> /// <returns>The matched files or folders.</returns> internal string[] GetAccessibleFileSystemEntries(FileMatcher.FileSystemEntity entityType, string path, string pattern, string projectDirectory, bool stripProjectDirectory) { string normalizedPath = Normalize(path); Hashtable files = new Hashtable(); if (entityType == FileMatcher.FileSystemEntity.Files || entityType == FileMatcher.FileSystemEntity.FilesAndDirectories) { _fileSet1Hits += GetMatchingFiles(_fileSet1, normalizedPath, pattern, files); _fileSet2Hits += GetMatchingFiles(_fileSet2, normalizedPath, pattern, files); _fileSet3Hits += GetMatchingFiles(_fileSet3, normalizedPath, pattern, files); } if (entityType == FileMatcher.FileSystemEntity.Directories || entityType == FileMatcher.FileSystemEntity.FilesAndDirectories) { GetMatchingDirectories(_fileSet1, normalizedPath, pattern, files); GetMatchingDirectories(_fileSet2, normalizedPath, pattern, files); GetMatchingDirectories(_fileSet3, normalizedPath, pattern, files); } ArrayList uniqueFiles = new ArrayList(); uniqueFiles.AddRange(files.Keys); return (string[])uniqueFiles.ToArray(typeof(string)); }
/// <summary> /// Simulate GetFileSystemEntries /// </summary> /// <param name="path"></param> /// <param name="pattern"></param> /// <returns>Array of matching file system entries (can be empty).</returns> private static string[] GetFileSystemEntriesLoopBack(FileMatcher.FileSystemEntity entityType, string path, string pattern, string projectDirectory, bool stripProjectDirectory) { return new string[] { Path.Combine(path, pattern) }; }
/// <summary> /// Method that is delegable for use by FileMatcher. This method simulates a filesystem by returning /// files and\or folders that match the requested path and pattern. /// </summary> /// <param name="entityType">Files, Directories or both</param> /// <param name="path">The path to search.</param> /// <param name="pattern">The pattern to search (may be null)</param> /// <returns>The matched files or folders.</returns> internal string[] GetAccessibleFileSystemEntries(FileMatcher.FileSystemEntity entityType, string path, string pattern, string projectDirectory, bool stripProjectDirectory) { string normalizedPath = Normalize(path); ISet<string> files = new HashSet<string>(); if (entityType == FileMatcher.FileSystemEntity.Files || entityType == FileMatcher.FileSystemEntity.FilesAndDirectories) { _fileSet1Hits += GetMatchingFiles(_fileSet1, normalizedPath, pattern, files); _fileSet2Hits += GetMatchingFiles(_fileSet2, normalizedPath, pattern, files); _fileSet3Hits += GetMatchingFiles(_fileSet3, normalizedPath, pattern, files); } if (entityType == FileMatcher.FileSystemEntity.Directories || entityType == FileMatcher.FileSystemEntity.FilesAndDirectories) { GetMatchingDirectories(_fileSet1, normalizedPath, pattern, files); GetMatchingDirectories(_fileSet2, normalizedPath, pattern, files); GetMatchingDirectories(_fileSet3, normalizedPath, pattern, files); } return files.ToArray(); }