예제 #1
0
        private IEnumerable <DirectoryInfo> InternalEnumerateDirectories(String searchPattern, SearchOption searchOption)
        {
            Contract.Requires(searchPattern != null);
            Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);

            return(FileSystemEnumerableFactory.CreateDirectoryInfoIterator(FullPath, OriginalPath, searchPattern, searchOption));
        }
예제 #2
0
        internal static IEnumerable <FileSystemInfo> InternalEnumerateInfos(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            Debug.Assert(path != null);
            if (searchPattern == null)
            {
                throw new ArgumentNullException(nameof(searchPattern));
            }

            FileSystemEnumerableFactory.NormalizeInputs(ref path, ref searchPattern, options);

            switch (searchTarget)
            {
            case SearchTarget.Directories:
                return(FileSystemEnumerableFactory.DirectoryInfos(path, searchPattern, options));

            case SearchTarget.Files:
                return(FileSystemEnumerableFactory.FileInfos(path, searchPattern, options));

            case SearchTarget.Both:
                return(FileSystemEnumerableFactory.FileSystemInfos(path, searchPattern, options));

            default:
                throw new ArgumentException(SR.ArgumentOutOfRange_Enum, nameof(searchTarget));
            }
        }
예제 #3
0
        internal static IEnumerable <string> InternalEnumeratePaths(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (searchPattern == null)
            {
                throw new ArgumentNullException(nameof(searchPattern));
            }

            FileSystemEnumerableFactory.NormalizeInputs(ref path, ref searchPattern, options);

            switch (searchTarget)
            {
            case SearchTarget.Files:
                return(FileSystemEnumerableFactory.UserFiles(path, searchPattern, options));

            case SearchTarget.Directories:
                return(FileSystemEnumerableFactory.UserDirectories(path, searchPattern, options));

            case SearchTarget.Both:
                return(FileSystemEnumerableFactory.UserEntries(path, searchPattern, options));

            default:
                throw new ArgumentOutOfRangeException(nameof(searchTarget));
            }
        }
예제 #4
0
        // Returns an array of Directories in the current DirectoryInfo matching the 
        // given search criteria (ie, "System*" could match the System & System32
        // directories).
        private DirectoryInfo[] InternalGetDirectories(String searchPattern, SearchOption searchOption)
        {
            Contract.Requires(searchPattern != null);
            Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);

            IEnumerable<DirectoryInfo> enble = FileSystemEnumerableFactory.CreateDirectoryInfoIterator(FullPath, OriginalPath, searchPattern, searchOption);
            List<DirectoryInfo> fileList = new List<DirectoryInfo>(enble);
            return fileList.ToArray();
        }
예제 #5
0
        private static IEnumerable <String> EnumerateFileSystemNames(String path, String searchPattern, SearchOption searchOption,
                                                                     bool includeFiles, bool includeDirs)
        {
            Debug.Assert(path != null);
            Debug.Assert(searchPattern != null);
            Debug.Assert(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);

            return(FileSystemEnumerableFactory.CreateFileNameIterator(path, path, searchPattern,
                                                                      includeFiles, includeDirs, searchOption, true));
        }
예제 #6
0
        private static IEnumerable <String> EnumerateFileSystemNames(String path, String searchPattern, SearchOption searchOption,
                                                                     bool includeFiles, bool includeDirs)
        {
            Contract.Requires(path != null);
            Contract.Requires(searchPattern != null);
            Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
            Contract.Ensures(Contract.Result <IEnumerable <String> >() != null);

            return(FileSystemEnumerableFactory.CreateFileNameIterator(path, path, searchPattern,
                                                                      includeFiles, includeDirs, searchOption, true));
        }
예제 #7
0
        // Returns fully qualified user path of dirs/files that matches the search parameters.
        // For recursive search this method will search through all the sub dirs  and execute
        // the given search criteria against every dir.
        // For all the dirs/files returned, it will then demand path discovery permission for
        // their parent folders (it will avoid duplicate permission checks)
        internal static String[] InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, bool includeFiles, bool includeDirs, SearchOption searchOption, bool checkHost)
        {
            Contract.Requires(path != null);
            Contract.Requires(userPathOriginal != null);
            Contract.Requires(searchPattern != null);
            Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);

            IEnumerable <String> enble = FileSystemEnumerableFactory.CreateFileNameIterator(
                path, userPathOriginal, searchPattern,
                includeFiles, includeDirs, searchOption, checkHost);
            List <String> fileList = new List <String>(enble);

            return(fileList.ToArray());
        }
예제 #8
0
        internal static IEnumerable <string> InternalEnumeratePaths(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            ArgumentNullException.ThrowIfNull(path);
            ArgumentNullException.ThrowIfNull(searchPattern);

            FileSystemEnumerableFactory.NormalizeInputs(ref path, ref searchPattern, options.MatchType);

            return(searchTarget switch
            {
                SearchTarget.Files => FileSystemEnumerableFactory.UserFiles(path, searchPattern, options),
                SearchTarget.Directories => FileSystemEnumerableFactory.UserDirectories(path, searchPattern, options),
                SearchTarget.Both => FileSystemEnumerableFactory.UserEntries(path, searchPattern, options),
                _ => throw new ArgumentOutOfRangeException(nameof(searchTarget)),
            });
예제 #9
0
        private IEnumerable <FileSystemInfo> InternalEnumerateInfos(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            ArgumentNullException.ThrowIfNull(searchPattern);

            Debug.Assert(path != null);

            _isNormalized &= FileSystemEnumerableFactory.NormalizeInputs(ref path, ref searchPattern, options.MatchType);

            return(searchTarget switch
            {
                SearchTarget.Directories => FileSystemEnumerableFactory.DirectoryInfos(path, searchPattern, options, _isNormalized),
                SearchTarget.Files => FileSystemEnumerableFactory.FileInfos(path, searchPattern, options, _isNormalized),
                SearchTarget.Both => FileSystemEnumerableFactory.FileSystemInfos(path, searchPattern, options, _isNormalized),
                _ => throw new ArgumentException(SR.ArgumentOutOfRange_Enum, nameof(searchTarget)),
            });
예제 #10
0
        internal static string[] InternalGetFileDirectoryNames(string path, string userPathOriginal, string searchPattern, bool includeFiles, bool includeDirs, SearchOption searchOption)
        {
            List <string> list = new List <string>(FileSystemEnumerableFactory.CreateFileNameIterator(path, userPathOriginal, searchPattern, includeFiles, includeDirs, searchOption));

            return(list.ToArray());
        }
예제 #11
0
 private static IEnumerable <string> EnumerateFileSystemNames(string path, string searchPattern, SearchOption searchOption, bool includeFiles, bool includeDirs)
 {
     return(FileSystemEnumerableFactory.CreateFileNameIterator(path, path, searchPattern, includeFiles, includeDirs, searchOption));
 }
        private FileSystemInfo[] InternalGetFileSystemInfos(string searchPattern, SearchOption searchOption)
        {
            List <FileSystemInfo> list = new List <FileSystemInfo>(FileSystemEnumerableFactory.CreateFileSystemInfoIterator(base.FullPath, base.OriginalPath, searchPattern, searchOption));

            return(list.ToArray());
        }
 private IEnumerable <FileSystemInfo> InternalEnumerateFileSystemInfos(string searchPattern, SearchOption searchOption)
 {
     return(FileSystemEnumerableFactory.CreateFileSystemInfoIterator(base.FullPath, base.OriginalPath, searchPattern, searchOption));
 }