3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 /*============================================================
8 ** Class: FileSystemEnumerable
10 ** <OWNER>[....]</OWNER>
13 ** Purpose: Enumerates files and dirs
15 ===========================================================*/
18 using System.Collections;
19 using System.Collections.Generic;
20 using System.Security;
21 using System.Security.Permissions;
22 using Microsoft.Win32;
23 using Microsoft.Win32.SafeHandles;
25 using System.Runtime.InteropServices;
26 using System.Globalization;
27 using System.Runtime.Versioning;
28 using System.Diagnostics.Contracts;
29 using System.Threading;
35 // The key methods instantiate FileSystemEnumerableIterators. These compose the iterator with search result
36 // handlers that instantiate the FileInfo, DirectoryInfo, String, etc. The handlers then perform any
37 // additional required permission demands.
38 internal static class FileSystemEnumerableFactory
40 internal static IEnumerable<String> CreateFileNameIterator(String path, String originalUserPath, String searchPattern,
41 bool includeFiles, bool includeDirs, SearchOption searchOption, bool checkHost)
43 Contract.Requires(path != null);
44 Contract.Requires(originalUserPath != null);
45 Contract.Requires(searchPattern != null);
47 SearchResultHandler<String> handler = new StringResultHandler(includeFiles, includeDirs);
48 return new FileSystemEnumerableIterator<String>(path, originalUserPath, searchPattern, searchOption, handler, checkHost);
51 internal static IEnumerable<FileInfo> CreateFileInfoIterator(String path, String originalUserPath, String searchPattern, SearchOption searchOption)
53 Contract.Requires(path != null);
54 Contract.Requires(originalUserPath != null);
55 Contract.Requires(searchPattern != null);
57 SearchResultHandler<FileInfo> handler = new FileInfoResultHandler();
58 return new FileSystemEnumerableIterator<FileInfo>(path, originalUserPath, searchPattern, searchOption, handler, true);
61 internal static IEnumerable<DirectoryInfo> CreateDirectoryInfoIterator(String path, String originalUserPath, String searchPattern, SearchOption searchOption)
64 Contract.Requires(path != null);
65 Contract.Requires(originalUserPath != null);
66 Contract.Requires(searchPattern != null);
68 SearchResultHandler<DirectoryInfo> handler = new DirectoryInfoResultHandler();
69 return new FileSystemEnumerableIterator<DirectoryInfo>(path, originalUserPath, searchPattern, searchOption, handler, true);
72 internal static IEnumerable<FileSystemInfo> CreateFileSystemInfoIterator(String path, String originalUserPath, String searchPattern, SearchOption searchOption)
74 Contract.Requires(path != null);
75 Contract.Requires(originalUserPath != null);
76 Contract.Requires(searchPattern != null);
78 SearchResultHandler<FileSystemInfo> handler = new FileSystemInfoResultHandler();
79 return new FileSystemEnumerableIterator<FileSystemInfo>(path, originalUserPath, searchPattern, searchOption, handler, true);
83 // Abstract Iterator, borrowed from Linq. Used in anticipation of need for similar enumerables
85 abstract internal class Iterator<TSource> : IEnumerable<TSource>, IEnumerator<TSource>
89 internal TSource current;
93 threadId = Thread.CurrentThread.ManagedThreadId;
96 public TSource Current
98 get { return current; }
101 protected abstract Iterator<TSource> Clone();
103 public void Dispose()
106 GC.SuppressFinalize(this);
109 protected virtual void Dispose(bool disposing)
111 current = default(TSource);
115 public IEnumerator<TSource> GetEnumerator()
117 if (threadId == Thread.CurrentThread.ManagedThreadId && state == 0)
123 Iterator<TSource> duplicate = Clone();
128 public abstract bool MoveNext();
130 object IEnumerator.Current
132 get { return Current; }
135 IEnumerator IEnumerable.GetEnumerator()
137 return GetEnumerator();
140 void IEnumerator.Reset()
142 throw new NotSupportedException();
148 // Enumerates file system entries matching the search parameters. For recursive searches this
149 // searches through all the sub dirs and executes the search criteria against every dir.
151 // Generic implementation:
152 // FileSystemEnumerableIterator is generic. When it gets a WIN32_FIND_DATA, it calls the
153 // result handler to create an instance of the generic type.
156 // Use FileSystemEnumerableFactory to obtain FSEnumerables that can enumerate file system
157 // entries as String path names, FileInfos, DirectoryInfos, or FileSystemInfos.
160 // For all the dirs/files returned, demands path discovery permission for their parent folders
161 internal class FileSystemEnumerableIterator<TSource> : Iterator<TSource>
164 private const int STATE_INIT = 1;
165 private const int STATE_SEARCH_NEXT_DIR = 2;
166 private const int STATE_FIND_NEXT_FILE = 3;
167 private const int STATE_FINISH = 4;
169 private SearchResultHandler<TSource> _resultHandler;
170 private List<Directory.SearchData> searchStack;
171 private Directory.SearchData searchData;
172 private String searchCriteria;
173 [System.Security.SecurityCritical]
174 SafeFindHandle _hnd = null;
175 bool needsParentPathDiscoveryDemand;
177 // empty means we know in advance that we won
\92t find any search results, which can happen if:
178 // 1. we don
\92t have a search pattern
179 // 2. we
\92re enumerating only the top directory and found no matches during the first call
180 // This flag allows us to return early for these cases. We can
\92t know this in advance for
181 // SearchOption.AllDirectories because we do a
\93*
\94 search for subdirs and then use the
182 // searchPattern at each directory level.
185 private String userPath;
186 private SearchOption searchOption;
187 private String fullPath;
188 private String normalizedSearchPath;
190 private bool _checkHost;
192 [System.Security.SecuritySafeCritical]
193 internal FileSystemEnumerableIterator(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler<TSource> resultHandler, bool checkHost)
195 Contract.Requires(path != null);
196 Contract.Requires(originalUserPath != null);
197 Contract.Requires(searchPattern != null);
198 Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
199 Contract.Requires(resultHandler != null);
201 oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS);
203 searchStack = new List<Directory.SearchData>();
205 String normalizedSearchPattern = NormalizeSearchPattern(searchPattern);
207 if (normalizedSearchPattern.Length == 0)
213 _resultHandler = resultHandler;
214 this.searchOption = searchOption;
216 fullPath = Path.GetFullPathInternal(path);
217 String fullSearchString = GetFullSearchString(fullPath, normalizedSearchPattern);
218 normalizedSearchPath = Path.GetDirectoryName(fullSearchString);
220 // permission demands
221 String[] demandPaths = new String[2];
222 // Any illegal chars such as *, ? will be caught by FileIOPermission.HasIllegalCharacters
223 demandPaths[0] = Directory.GetDemandDir(fullPath, true);
224 // For filters like foo\*.cs we need to verify if the directory foo is not denied access.
225 // Do a demand on the combined path so that we can fail early in case of deny
226 demandPaths[1] = Directory.GetDemandDir(normalizedSearchPath, true);
227 _checkHost = checkHost;
231 FileSecurityState state1 = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandPaths[0]);
232 state1.EnsureState();
233 FileSecurityState state2 = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandPaths[1]);
234 state2.EnsureState();
237 FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandPaths, false, false);
240 // normalize search criteria
241 searchCriteria = GetNormalizedSearchCriteria(fullSearchString, normalizedSearchPath);
244 String searchPatternDirName = Path.GetDirectoryName(normalizedSearchPattern);
245 String userPathTemp = originalUserPath;
246 if (searchPatternDirName != null && searchPatternDirName.Length != 0)
248 userPathTemp = Path.Combine(userPathTemp, searchPatternDirName);
250 this.userPath = userPathTemp;
252 searchData = new Directory.SearchData(normalizedSearchPath, this.userPath, searchOption);
259 [System.Security.SecurityCritical]
260 private void CommonInit()
262 Contract.Assert(searchCriteria != null && searchData != null, "searchCriteria and searchData should be initialized");
264 // Execute searchCriteria against the current directory
265 String searchPath = Path.InternalCombine(searchData.fullPath, searchCriteria);
267 Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA();
269 // Open a Find handle
270 _hnd = Win32Native.FindFirstFile(searchPath, data);
274 int hr = Marshal.GetLastWin32Error();
275 if (hr != Win32Native.ERROR_FILE_NOT_FOUND && hr != Win32Native.ERROR_NO_MORE_FILES)
277 HandleError(hr, searchData.fullPath);
281 // flag this as empty only if we're searching just top directory
282 // Used in fast path for top directory only
283 empty = searchData.searchOption == SearchOption.TopDirectoryOnly;
286 // fast path for TopDirectoryOnly. If we have a result, go ahead and set it to
287 // current. If empty, dispose handle.
288 if (searchData.searchOption == SearchOption.TopDirectoryOnly)
296 SearchResult searchResult = CreateSearchResult(searchData, data);
297 if (_resultHandler.IsResultIncluded(searchResult))
299 current = _resultHandler.CreateObject(searchResult);
303 // for AllDirectories, we first recurse into dirs, so cleanup and add searchData
308 searchStack.Add(searchData);
312 [System.Security.SecuritySafeCritical]
313 private FileSystemEnumerableIterator(String fullPath, String normalizedSearchPath, String searchCriteria, String userPath, SearchOption searchOption, SearchResultHandler<TSource> resultHandler, bool checkHost)
315 this.fullPath = fullPath;
316 this.normalizedSearchPath = normalizedSearchPath;
317 this.searchCriteria = searchCriteria;
318 this._resultHandler = resultHandler;
319 this.userPath = userPath;
320 this.searchOption = searchOption;
321 this._checkHost = checkHost;
323 searchStack = new List<Directory.SearchData>();
325 if (searchCriteria != null)
327 // permission demands
328 String[] demandPaths = new String[2];
329 // Any illegal chars such as *, ? will be caught by FileIOPermission.HasIllegalCharacters
330 demandPaths[0] = Directory.GetDemandDir(fullPath, true);
331 // For filters like foo\*.cs we need to verify if the directory foo is not denied access.
332 // Do a demand on the combined path so that we can fail early in case of deny
333 demandPaths[1] = Directory.GetDemandDir(normalizedSearchPath, true);
337 FileSecurityState state1 = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandPaths[0]);
338 state1.EnsureState();
339 FileSecurityState state2 = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandPaths[1]);
340 state2.EnsureState();
343 FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandPaths, false, false);
345 searchData = new Directory.SearchData(normalizedSearchPath, userPath, searchOption);
354 protected override Iterator<TSource> Clone()
356 return new FileSystemEnumerableIterator<TSource>(fullPath, normalizedSearchPath, searchCriteria, userPath, searchOption, _resultHandler, _checkHost);
359 [System.Security.SecuritySafeCritical]
360 protected override void Dispose(bool disposing)
371 Win32Native.SetErrorMode(oldMode);
372 base.Dispose(disposing);
376 [System.Security.SecuritySafeCritical]
377 public override bool MoveNext()
379 Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA();
386 state = STATE_FINISH;
387 goto case STATE_FINISH;
389 if (searchData.searchOption == SearchOption.TopDirectoryOnly)
391 state = STATE_FIND_NEXT_FILE;
398 goto case STATE_FIND_NEXT_FILE;
403 state = STATE_SEARCH_NEXT_DIR;
404 goto case STATE_SEARCH_NEXT_DIR;
407 case STATE_SEARCH_NEXT_DIR:
409 Contract.Assert(searchData.searchOption != SearchOption.TopDirectoryOnly, "should not reach this code path if searchOption == TopDirectoryOnly");
410 // Traverse directory structure. We need to get '*'
411 while (searchStack.Count > 0)
413 searchData = searchStack[0];
414 Contract.Assert((searchData.fullPath != null), "fullpath can't be null!");
415 searchStack.RemoveAt(0);
417 // Traverse the subdirs
418 AddSearchableDirsToStack(searchData);
420 // Execute searchCriteria against the current directory
421 String searchPath = Path.InternalCombine(searchData.fullPath, searchCriteria);
423 // Open a Find handle
424 _hnd = Win32Native.FindFirstFile(searchPath, data);
427 int hr = Marshal.GetLastWin32Error();
428 if (hr == Win32Native.ERROR_FILE_NOT_FOUND || hr == Win32Native.ERROR_NO_MORE_FILES || hr == Win32Native.ERROR_PATH_NOT_FOUND)
432 HandleError(hr, searchData.fullPath);
435 state = STATE_FIND_NEXT_FILE;
436 needsParentPathDiscoveryDemand = true;
437 SearchResult searchResult = CreateSearchResult(searchData, data);
438 if (_resultHandler.IsResultIncluded(searchResult))
440 if (needsParentPathDiscoveryDemand)
442 DoDemand(searchData.fullPath);
443 needsParentPathDiscoveryDemand = false;
445 current = _resultHandler.CreateObject(searchResult);
450 goto case STATE_FIND_NEXT_FILE;
453 state = STATE_FINISH;
454 goto case STATE_FINISH;
456 case STATE_FIND_NEXT_FILE:
458 if (searchData != null && _hnd != null)
460 // Keep asking for more matching files/dirs, add it to the list
461 while (Win32Native.FindNextFile(_hnd, data))
463 SearchResult searchResult = CreateSearchResult(searchData, data);
464 if (_resultHandler.IsResultIncluded(searchResult))
466 if (needsParentPathDiscoveryDemand)
468 DoDemand(searchData.fullPath);
469 needsParentPathDiscoveryDemand = false;
471 current = _resultHandler.CreateObject(searchResult);
476 // Make sure we quit with a sensible error.
477 int hr = Marshal.GetLastWin32Error();
482 // ERROR_FILE_NOT_FOUND is valid here because if the top level
483 // dir doen't contain any subdirs and matching files then
484 // we will get here with this errorcode from the searchStack walk
485 if ((hr != 0) && (hr != Win32Native.ERROR_NO_MORE_FILES)
486 && (hr != Win32Native.ERROR_FILE_NOT_FOUND))
488 HandleError(hr, searchData.fullPath);
491 if (searchData.searchOption == SearchOption.TopDirectoryOnly)
493 state = STATE_FINISH;
494 goto case STATE_FINISH;
498 state = STATE_SEARCH_NEXT_DIR;
499 goto case STATE_SEARCH_NEXT_DIR;
511 [System.Security.SecurityCritical]
512 private SearchResult CreateSearchResult(Directory.SearchData localSearchData, Win32Native.WIN32_FIND_DATA findData)
514 String userPathFinal = Path.InternalCombine(localSearchData.userPath, findData.cFileName);
515 String fullPathFinal = Path.InternalCombine(localSearchData.fullPath, findData.cFileName);
516 return new SearchResult(fullPathFinal, userPathFinal, findData);
519 [System.Security.SecurityCritical]
520 private void HandleError(int hr, String path)
523 __Error.WinIOError(hr, path);
526 [System.Security.SecurityCritical] // auto-generated
527 private void AddSearchableDirsToStack(Directory.SearchData localSearchData)
529 Contract.Requires(localSearchData != null);
531 String searchPath = Path.InternalCombine(localSearchData.fullPath, "*");
532 SafeFindHandle hnd = null;
533 Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA();
536 // Get all files and dirs
537 hnd = Win32Native.FindFirstFile(searchPath, data);
541 int hr = Marshal.GetLastWin32Error();
543 // This could happen if the dir doesn't contain any files.
544 // Continue with the recursive search though, eventually
545 // searchStack will become empty
546 if (hr == Win32Native.ERROR_FILE_NOT_FOUND || hr == Win32Native.ERROR_NO_MORE_FILES || hr == Win32Native.ERROR_PATH_NOT_FOUND)
549 HandleError(hr, localSearchData.fullPath);
552 // Add subdirs to searchStack. Exempt ReparsePoints as appropriate
556 if (FileSystemEnumerableHelpers.IsDir(data))
558 String tempFullPath = Path.InternalCombine(localSearchData.fullPath, data.cFileName);
559 String tempUserPath = Path.InternalCombine(localSearchData.userPath, data.cFileName);
561 SearchOption option = localSearchData.searchOption;
563 #if EXCLUDE_REPARSEPOINTS
564 // Traverse reparse points depending on the searchoption specified
565 if ((searchDataSubDir.searchOption == SearchOption.AllDirectories) && (0 != (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_REPARSE_POINT)))
566 option = SearchOption.TopDirectoryOnly;
568 // Setup search data for the sub directory and push it into the stack
569 Directory.SearchData searchDataSubDir = new Directory.SearchData(tempFullPath, tempUserPath, option);
571 searchStack.Insert(incr++, searchDataSubDir);
573 } while (Win32Native.FindNextFile(hnd, data));
574 // We don't care about errors here
583 [System.Security.SecurityCritical]
584 internal void DoDemand(String fullPathToDemand)
588 String demandDir = Directory.GetDemandDir(fullPathToDemand, true);
589 FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandDir);
593 String demandDir = Directory.GetDemandDir(fullPathToDemand, true);
594 FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandDir, false, false);
598 private static String NormalizeSearchPattern(String searchPattern)
600 Contract.Requires(searchPattern != null);
602 // Win32 normalization trims only U+0020.
603 String tempSearchPattern = searchPattern.TrimEnd(Path.TrimEndChars);
605 // Make this corner case more useful, like dir
606 if (tempSearchPattern.Equals("."))
608 tempSearchPattern = "*";
611 Path.CheckSearchPattern(tempSearchPattern);
612 return tempSearchPattern;
615 private static String GetNormalizedSearchCriteria(String fullSearchString, String fullPathMod)
617 Contract.Requires(fullSearchString != null);
618 Contract.Requires(fullPathMod != null);
619 Contract.Requires(fullSearchString.Length >= fullPathMod.Length);
621 String searchCriteria = null;
622 char lastChar = fullPathMod[fullPathMod.Length - 1];
623 if (Path.IsDirectorySeparator(lastChar))
625 // Can happen if the path is C:\temp, in which case GetDirectoryName would return C:\
626 searchCriteria = fullSearchString.Substring(fullPathMod.Length);
630 Contract.Assert(fullSearchString.Length > fullPathMod.Length);
631 searchCriteria = fullSearchString.Substring(fullPathMod.Length + 1);
633 return searchCriteria;
636 private static String GetFullSearchString(String fullPath, String searchPattern)
638 Contract.Requires(fullPath != null);
639 Contract.Requires(searchPattern != null);
641 String tempStr = Path.InternalCombine(fullPath, searchPattern);
643 // If path ends in a trailing slash (\), append a * or we'll get a "Cannot find the file specified" exception
644 char lastChar = tempStr[tempStr.Length - 1];
645 if (Path.IsDirectorySeparator(lastChar) || lastChar == Path.VolumeSeparatorChar)
647 tempStr = tempStr + '*';
654 internal abstract class SearchResultHandler<TSource>
657 [System.Security.SecurityCritical]
658 internal abstract bool IsResultIncluded(SearchResult result);
660 [System.Security.SecurityCritical]
661 internal abstract TSource CreateObject(SearchResult result);
665 internal class StringResultHandler : SearchResultHandler<String>
667 private bool _includeFiles;
668 private bool _includeDirs;
670 internal StringResultHandler(bool includeFiles, bool includeDirs)
672 _includeFiles = includeFiles;
673 _includeDirs = includeDirs;
676 [System.Security.SecurityCritical]
677 internal override bool IsResultIncluded(SearchResult result)
679 bool includeFile = _includeFiles && FileSystemEnumerableHelpers.IsFile(result.FindData);
680 bool includeDir = _includeDirs && FileSystemEnumerableHelpers.IsDir(result.FindData);
681 Contract.Assert(!(includeFile && includeDir), result.FindData.cFileName + ": current item can't be both file and dir!");
682 return (includeFile || includeDir);
685 [System.Security.SecurityCritical]
686 internal override String CreateObject(SearchResult result)
688 return result.UserPath;
692 internal class FileInfoResultHandler : SearchResultHandler<FileInfo>
694 [System.Security.SecurityCritical]
695 internal override bool IsResultIncluded(SearchResult result)
697 return FileSystemEnumerableHelpers.IsFile(result.FindData);
700 [System.Security.SecurityCritical]
701 internal override FileInfo CreateObject(SearchResult result)
703 String name = result.FullPath;
705 FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name);
708 FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, name, false, false);
710 FileInfo fi = new FileInfo(name, false);
711 fi.InitializeFrom(result.FindData);
716 internal class DirectoryInfoResultHandler : SearchResultHandler<DirectoryInfo>
718 [System.Security.SecurityCritical]
719 internal override bool IsResultIncluded(SearchResult result)
721 return FileSystemEnumerableHelpers.IsDir(result.FindData);
724 [System.Security.SecurityCritical]
725 internal override DirectoryInfo CreateObject(SearchResult result)
727 String name = result.FullPath;
728 String permissionName = name + "\\.";
731 FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
734 FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, permissionName, false, false);
736 DirectoryInfo di = new DirectoryInfo(name, false);
737 di.InitializeFrom(result.FindData);
742 internal class FileSystemInfoResultHandler : SearchResultHandler<FileSystemInfo>
745 [System.Security.SecurityCritical]
746 internal override bool IsResultIncluded(SearchResult result)
748 bool includeFile = FileSystemEnumerableHelpers.IsFile(result.FindData);
749 bool includeDir = FileSystemEnumerableHelpers.IsDir(result.FindData);
750 Contract.Assert(!(includeFile && includeDir), result.FindData.cFileName + ": current item can't be both file and dir!");
752 return (includeDir || includeFile);
755 [System.Security.SecurityCritical]
756 internal override FileSystemInfo CreateObject(SearchResult result)
758 bool isFile = FileSystemEnumerableHelpers.IsFile(result.FindData);
759 bool isDir = FileSystemEnumerableHelpers.IsDir(result.FindData);
763 String name = result.FullPath;
764 String permissionName = name + "\\.";
767 FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
770 FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, permissionName, false, false);
772 DirectoryInfo di = new DirectoryInfo(name, false);
773 di.InitializeFrom(result.FindData);
778 Contract.Assert(isFile);
779 String name = result.FullPath;
782 FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name);
785 FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, name, false, false);
787 FileInfo fi = new FileInfo(name, false);
788 fi.InitializeFrom(result.FindData);
795 internal sealed class SearchResult
797 private String fullPath; // fully-qualifed path
798 private String userPath; // user-specified path
799 [System.Security.SecurityCritical]
800 private Win32Native.WIN32_FIND_DATA findData;
802 [System.Security.SecurityCritical]
803 internal SearchResult(String fullPath, String userPath, Win32Native.WIN32_FIND_DATA findData)
805 Contract.Requires(fullPath != null);
806 Contract.Requires(userPath != null);
808 this.fullPath = fullPath;
809 this.userPath = userPath;
810 this.findData = findData;
813 internal String FullPath
815 get { return fullPath; }
818 internal String UserPath
820 get { return userPath; }
823 internal Win32Native.WIN32_FIND_DATA FindData
825 [System.Security.SecurityCritical]
826 get { return findData; }
831 internal static class FileSystemEnumerableHelpers
833 [System.Security.SecurityCritical] // auto-generated
834 internal static bool IsDir(Win32Native.WIN32_FIND_DATA data)
836 // Don't add "." nor ".."
837 return (0 != (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY))
838 && !data.cFileName.Equals(".") && !data.cFileName.Equals("..");
841 [System.Security.SecurityCritical] // auto-generated
842 internal static bool IsFile(Win32Native.WIN32_FIND_DATA data)
844 return 0 == (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY);