/* * Method: GetFileSystemEntries * Owner: jomof * * 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); Assertion.Assert("Unexpected input into GetFileSystemEntries", false); } 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) }; }