internal override FileSystemInfo CreateObject(SearchResult result) { FileSystemEnumerableHelpers.IsFile(result.FindData); if (FileSystemEnumerableHelpers.IsDir(result.FindData)) { string fullPath = result.FullPath; new FileIOPermission(FileIOPermissionAccess.Read, new string[1] { fullPath + "\\." }, false, false).Demand(); DirectoryInfo directoryInfo = new DirectoryInfo(fullPath, false); Win32Native.WIN32_FIND_DATA findData = result.FindData; directoryInfo.InitializeFrom(findData); return((FileSystemInfo)directoryInfo); } string fullPath1 = result.FullPath; new FileIOPermission(FileIOPermissionAccess.Read, new string[1] { fullPath1 }, false, false).Demand(); FileInfo fileInfo = new FileInfo(fullPath1, false); Win32Native.WIN32_FIND_DATA findData1 = result.FindData; fileInfo.InitializeFrom(findData1); return((FileSystemInfo)fileInfo); }
internal override FileSystemInfo CreateObject(SearchResult result) { bool isFile = FileSystemEnumerableHelpers.IsFile(result.FindData); bool isDir = FileSystemEnumerableHelpers.IsDir(result.FindData); if (isDir) { String name = result.FullPath; String permissionName = name + "\\."; FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName); state.EnsureState(); DirectoryInfo di = new DirectoryInfo(name, false); di.InitializeFrom(result.FindData); return(di); } else { Debug.Assert(isFile); String name = result.FullPath; FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name); state.EnsureState(); FileInfo fi = new FileInfo(name, false); fi.InitializeFrom(result.FindData); return(fi); } }
internal override bool IsResultIncluded(SearchResult result) { bool includeFile = _includeFiles && FileSystemEnumerableHelpers.IsFile(result.FindData); bool includeDir = _includeDirs && FileSystemEnumerableHelpers.IsDir(result.FindData); Contract.Assert(!(includeFile && includeDir), result.FindData.cFileName + ": current item can't be both file and dir!"); return(includeFile || includeDir); }
internal override bool IsResultIncluded(SearchResult result) { bool flag = FileSystemEnumerableHelpers.IsFile(result.FindData); if (!FileSystemEnumerableHelpers.IsDir(result.FindData)) { return(flag); } return(true); }
internal override bool IsResultIncluded(SearchResult result) { bool flag = this._includeFiles && FileSystemEnumerableHelpers.IsFile(result.FindData); bool flag2 = this._includeDirs && FileSystemEnumerableHelpers.IsDir(result.FindData); if (!flag) { return(flag2); } return(true); }
private void AddSearchableDirsToStack(Directory.SearchData localSearchData) { string fileName = Path.InternalCombine(localSearchData.fullPath, "*"); SafeFindHandle hndFindFile = (SafeFindHandle)null; Win32Native.WIN32_FIND_DATA wiN32FindData = new Win32Native.WIN32_FIND_DATA(); try { hndFindFile = Win32Native.FindFirstFile(fileName, wiN32FindData); if (hndFindFile.IsInvalid) { int lastWin32Error = Marshal.GetLastWin32Error(); switch (lastWin32Error) { case 2: return; case 18: return; case 3: return; default: this.HandleError(lastWin32Error, localSearchData.fullPath); break; } } int num1 = 0; do { if (FileSystemEnumerableHelpers.IsDir(wiN32FindData)) { string fullPath = Path.InternalCombine(localSearchData.fullPath, wiN32FindData.cFileName); string str = Path.InternalCombine(localSearchData.userPath, wiN32FindData.cFileName); SearchOption searchOption = localSearchData.searchOption; string userPath = str; int num2 = (int)searchOption; Directory.SearchData searchData = new Directory.SearchData(fullPath, userPath, (SearchOption)num2); this.searchStack.Insert(num1++, searchData); } }while (Win32Native.FindNextFile(hndFindFile, wiN32FindData)); } finally { if (hndFindFile != null) { hndFindFile.Dispose(); } } }
internal override FileSystemInfo CreateObject(SearchResult result) { bool isFile = FileSystemEnumerableHelpers.IsFile(result.FindData); bool isDir = FileSystemEnumerableHelpers.IsDir(result.FindData); if (isDir) { DirectoryInfo di = new DirectoryInfo(result.FullPath, false); di.InitializeFrom(result.FindData); return(di); } else { Contract.Assert(isFile); FileInfo fi = new FileInfo(result.FullPath, false); fi.InitializeFrom(result.FindData); return(fi); } }
internal override FileSystemInfo CreateObject(SearchResult result) { FileSystemEnumerableHelpers.IsFile(result.FindData); if (FileSystemEnumerableHelpers.IsDir(result.FindData)) { string str = result.FullPath; string str2 = str + @"\."; string[] strArray = new string[] { str2 }; new FileIOPermission(FileIOPermissionAccess.Read, strArray, false, false).Demand(); DirectoryInfo info = new DirectoryInfo(str, false); info.InitializeFrom(result.FindData); return(info); } string fullPath = result.FullPath; string[] pathList = new string[] { fullPath }; new FileIOPermission(FileIOPermissionAccess.Read, pathList, false, false).Demand(); FileInfo info2 = new FileInfo(fullPath, false); info2.InitializeFrom(result.FindData); return(info2); }
internal override FileSystemInfo CreateObject(SearchResult result) { bool isFile = FileSystemEnumerableHelpers.IsFile(result.FindData); bool isDir = FileSystemEnumerableHelpers.IsDir(result.FindData); if (isDir) { String name = result.FullPath; String permissionName = name + "\\."; #if FEATURE_CORECLR FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName); state.EnsureState(); #else String[] permissionNames = new String[] { permissionName }; new FileIOPermission(FileIOPermissionAccess.Read, permissionNames, false, false).Demand(); #endif DirectoryInfo di = new DirectoryInfo(name, false); di.InitializeFrom(result.FindData); return(di); } else { Contract.Assert(isFile); String name = result.FullPath; #if FEATURE_CORECLR FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name); state.EnsureState(); #else String[] names = new String[] { name }; new FileIOPermission(FileIOPermissionAccess.Read, names, false, false).Demand(); #endif FileInfo fi = new FileInfo(name, false); fi.InitializeFrom(result.FindData); return(fi); } }
private void AddSearchableDirsToStack(Directory.SearchData localSearchData) { string fileName = localSearchData.fullPath + "*"; SafeFindHandle hndFindFile = null; Win32Native.WIN32_FIND_DATA win_find_data = new Win32Native.WIN32_FIND_DATA(); using (hndFindFile = Win32Native.FindFirstFile(fileName, win_find_data)) { if (hndFindFile.IsInvalid) { int hr = Marshal.GetLastWin32Error(); switch (hr) { case 2: case 0x12: case 3: return; } this.HandleError(hr, localSearchData.fullPath); } int num2 = 0; do { if (FileSystemEnumerableHelpers.IsDir(win_find_data)) { StringBuilder builder = new StringBuilder(localSearchData.fullPath); builder.Append(win_find_data.cFileName); string fullPath = builder.ToString(); builder.Length = 0; builder.Append(localSearchData.userPath); builder.Append(win_find_data.cFileName); SearchOption searchOption = localSearchData.searchOption; Directory.SearchData item = new Directory.SearchData(fullPath, builder.ToString(), searchOption); this.searchStack.Insert(num2++, item); } }while (Win32Native.FindNextFile(hndFindFile, win_find_data)); } }
internal override bool IsResultIncluded(SearchResult result) { return(((!this._includeFiles ? 0 : (FileSystemEnumerableHelpers.IsFile(result.FindData) ? 1 : 0)) | (!this._includeDirs ? (false ? 1 : 0) : (FileSystemEnumerableHelpers.IsDir(result.FindData) ? 1 : 0))) != 0); }
internal override bool IsResultIncluded(SearchResult result) { return(FileSystemEnumerableHelpers.IsDir(result.FindData)); }
[System.Security.SecurityCritical] // auto-generated private void AddSearchableDirsToStack(Directory.SearchData localSearchData) { Contract.Requires(localSearchData != null); String searchPath = Path.InternalCombine(localSearchData.fullPath, "*"); SafeFindHandle hnd = null; Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA(); try { // Get all files and dirs hnd = Win32Native.FindFirstFile(searchPath, data); if (hnd.IsInvalid) { int hr = Marshal.GetLastWin32Error(); // This could happen if the dir doesn't contain any files. // Continue with the recursive search though, eventually // searchStack will become empty if (hr == Win32Native.ERROR_FILE_NOT_FOUND || hr == Win32Native.ERROR_NO_MORE_FILES || hr == Win32Native.ERROR_PATH_NOT_FOUND) { return; } HandleError(hr, localSearchData.fullPath); } // Add subdirs to searchStack. Exempt ReparsePoints as appropriate int incr = 0; do { if (FileSystemEnumerableHelpers.IsDir(data)) { String tempFullPath = Path.InternalCombine(localSearchData.fullPath, data.cFileName); String tempUserPath = Path.InternalCombine(localSearchData.userPath, data.cFileName); SearchOption option = localSearchData.searchOption; #if EXCLUDE_REPARSEPOINTS // Traverse reparse points depending on the searchoption specified if ((searchDataSubDir.searchOption == SearchOption.AllDirectories) && (0 != (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_REPARSE_POINT))) { option = SearchOption.TopDirectoryOnly; } #endif // Setup search data for the sub directory and push it into the stack Directory.SearchData searchDataSubDir = new Directory.SearchData(tempFullPath, tempUserPath, option); searchStack.Insert(incr++, searchDataSubDir); } } while (Win32Native.FindNextFile(hnd, data)); // We don't care about errors here } finally { if (hnd != null) { hnd.Dispose(); } } }