/// <summary> /// Creates a shallow copy of the <see cref="StringCollectionWithGoodToString" />. /// </summary> /// <returns> /// A shallow copy of the <see cref="StringCollectionWithGoodToString" />. /// </returns> public virtual object Clone() { string[] strings = new string[Count]; CopyTo(strings, 0); StringCollectionWithGoodToString clone = new StringCollectionWithGoodToString(); clone.AddRange(strings); return(clone); }
private void Reset() { _includePatterns = null; _includeNames = null; _excludePatterns = null; _excludeNames = null; _fileNames = null; _directoryNames = null; _searchDirectories = null; _searchDirIsRecursive = null; _scannedDirectories = null; }
/// <summary> /// Uses <see cref="Includes" /> and <see cref="Excludes" /> search criteria (relative to /// <see cref="BaseDirectory" /> or absolute), to search for filesystem objects. /// </summary> public void Scan() { _includePatterns = new ArrayList(); _includeNames = new StringCollectionWithGoodToString(); _excludePatterns = new ArrayList(); _excludeNames = new StringCollectionWithGoodToString(); _fileNames = new StringCollectionWithGoodToString(); _directoryNames = new DirScannerStringCollection(CaseSensitive); _searchDirectories = new DirScannerStringCollection(CaseSensitive); _searchDirIsRecursive = new ArrayList(); _scannedDirectories = new DirScannerStringCollection(CaseSensitive); #if DEBUG_REGEXES Console.WriteLine("*********************************************************************"); Console.WriteLine("DirectoryScanner.Scan()"); Console.WriteLine("*********************************************************************"); Console.WriteLine(new System.Diagnostics.StackTrace().ToString()); Console.WriteLine("Base Directory: " + BaseDirectory.FullName); Console.WriteLine("Includes:"); foreach (string strPattern in _includes) { Console.WriteLine(strPattern); } Console.WriteLine("Excludes:"); foreach (string strPattern in _excludes) { Console.WriteLine(strPattern); } Console.WriteLine("--- Starting Scan ---"); #endif // convert given NAnt patterns to regex patterns with absolute paths // side effect: searchDirectories will be populated ConvertPatterns(_includes, _includePatterns, _includeNames, true); ConvertPatterns(_excludes, _excludePatterns, _excludeNames, false); for (int index = 0; index < _searchDirectories.Count; index++) { ScanDirectory(_searchDirectories[index], (bool)_searchDirIsRecursive[index]); } #if DEBUG_REGEXES Console.WriteLine("*********************************************************************"); #endif }
private void Reset () { _isEverythingIncluded = true; _hasEmptyDirectories = false; _baseDirFileSystem.Clear(); _includePatterns = null; _includeNames = null; _excludePatterns = null; _excludeNames = null; _fileNames = null; _directoryNames = null; _excludedFileNames = null; _excludedDirectoryNames = null; _searchDirectories = null; _searchDirIsRecursive = null; _scannedDirectories = null; }
/// <summary> /// Uses <see cref="Includes" /> and <see cref="Excludes" /> search criteria (relative to /// <see cref="BaseDirectory" /> or absolute), to search for filesystem objects. /// </summary> public void Scan() { Thread getDirList; _includePatterns = new ArrayList(); _includeNames = new StringCollectionWithGoodToString (); _excludePatterns = new ArrayList(); _excludeNames = new StringCollectionWithGoodToString (); _fileNames = new StringCollectionWithGoodToString (); _directoryNames = new DirScannerStringCollection(CaseSensitive); _excludedFileNames = new StringCollectionWithGoodToString(); _excludedDirectoryNames = new DirScannerStringCollection(CaseSensitive); _searchDirectories = new DirScannerStringCollection(CaseSensitive); _searchDirIsRecursive = new ArrayList(); _scannedDirectories = new DirScannerStringCollection(CaseSensitive); #if DEBUG_REGEXES Console.WriteLine("*********************************************************************"); Console.WriteLine("DirectoryScanner.Scan()"); Console.WriteLine("*********************************************************************"); Console.WriteLine(new System.Diagnostics.StackTrace().ToString()); Console.WriteLine("Base Directory: " + BaseDirectory.FullName); Console.WriteLine("Includes:"); foreach (string strPattern in _includes) Console.WriteLine(strPattern); Console.WriteLine("Excludes:"); foreach (string strPattern in _excludes) Console.WriteLine(strPattern); Console.WriteLine("--- Starting Scan ---"); #endif // Begin scanning the base directory file system if (_baseDirFileSystem != null) _baseDirFileSystem.Clear(); // Gather all of the file system info objects in the background while // scan is performing. Hoping this will save some time. getDirList = new Thread(new ParameterizedThreadStart(GetAllFileSystemInfo)); getDirList.IsBackground = true; getDirList.Start(BaseDirectory); // convert given NAnt patterns to regex patterns with absolute paths // side effect: searchDirectories will be populated ConvertPatterns(_includes, _includePatterns, _includeNames, true); ConvertPatterns(_excludes, _excludePatterns, _excludeNames, false); for (int index = 0; index < _searchDirectories.Count; index++) { ScanDirectory(_searchDirectories[index], (bool) _searchDirIsRecursive[index]); } // Wait for the directory scan to finish before checking if // everything is included and if there are any empty directories. getDirList.Join(); // Run both "Check" methods in parallel. #if NET_4_0 Parallel.Invoke(CheckHasEmptyDirectories, CheckIsEverythingIncluded); #else Thread[] lastTasks = new Thread[2]; lastTasks[0] = new Thread(new ThreadStart(CheckHasEmptyDirectories)); lastTasks[1] = new Thread(new ThreadStart(CheckIsEverythingIncluded)); foreach (Thread t in lastTasks) { t.IsBackground = true; t.Start(); } foreach (Thread t in lastTasks) t.Join(); #endif #if DEBUG_REGEXES Console.WriteLine("*********************************************************************"); #endif }
/// <summary> /// Creates a shallow copy of the <see cref="StringCollectionWithGoodToString" />. /// </summary> /// <returns> /// A shallow copy of the <see cref="StringCollectionWithGoodToString" />. /// </returns> public virtual object Clone() { string[] strings = new string[Count]; CopyTo(strings, 0); StringCollectionWithGoodToString clone = new StringCollectionWithGoodToString(); clone.AddRange(strings); return clone; }
/// <summary> /// Uses <see cref="Includes" /> and <see cref="Excludes" /> search criteria (relative to /// <see cref="BaseDirectory" /> or absolute), to search for filesystem objects. /// </summary> public void Scan() { _includePatterns = new ArrayList(); _includeNames = new StringCollectionWithGoodToString (); _excludePatterns = new ArrayList(); _excludeNames = new StringCollectionWithGoodToString (); _fileNames = new StringCollectionWithGoodToString (); _directoryNames = new DirScannerStringCollection(CaseSensitive); _searchDirectories = new DirScannerStringCollection(CaseSensitive); _searchDirIsRecursive = new ArrayList(); _scannedDirectories = new DirScannerStringCollection(CaseSensitive); #if DEBUG_REGEXES Console.WriteLine("*********************************************************************"); Console.WriteLine("DirectoryScanner.Scan()"); Console.WriteLine("*********************************************************************"); Console.WriteLine(new System.Diagnostics.StackTrace().ToString()); Console.WriteLine("Base Directory: " + BaseDirectory.FullName); Console.WriteLine("Includes:"); foreach (string strPattern in _includes) Console.WriteLine(strPattern); Console.WriteLine("Excludes:"); foreach (string strPattern in _excludes) Console.WriteLine(strPattern); Console.WriteLine("--- Starting Scan ---"); #endif // convert given NAnt patterns to regex patterns with absolute paths // side effect: searchDirectories will be populated ConvertPatterns(_includes, _includePatterns, _includeNames, true); ConvertPatterns(_excludes, _excludePatterns, _excludeNames, false); for (int index = 0; index < _searchDirectories.Count; index++) { ScanDirectory(_searchDirectories[index], (bool) _searchDirIsRecursive[index]); } #if DEBUG_REGEXES Console.WriteLine("*********************************************************************"); #endif }