Exemple #1
0
        private IEnumerable <FileSystemInfo> InternalEnumerateInfos(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            Debug.Assert(path != null);
            if (searchPattern == null)
            {
                throw new ArgumentNullException(nameof(searchPattern));
            }

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

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

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

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

            default:
                throw new ArgumentException(SR.ArgumentOutOfRange_Enum, nameof(searchTarget));
            }
        }
Exemple #2
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.MatchType);

            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));
            }
        }