示例#1
0
            /// <nodoc />
            private bool Equals(EnumeratePathKey other)
            {
                if (ReferenceEquals(this, other))
                {
                    return(true);
                }

                // Path and search pattern comparisons are case-sensitive for the following reasons:
                // - The path should come from AbsolutePath, and PathTable gives a consisten path in terms of casing.
                // - This is an optimization for generated specs where paths and search patterns have consistent casing.
                // - As an optimization, it is OK to miss just because difference in casing.
                // - Comparison will work for X-platform.
                return(other != null &&
                       string.Equals(Path, other.Path) &&
                       string.Equals(SearchPattern, other.SearchPattern) &&
                       IsRecursive == other.IsRecursive &&
                       EnumerateDirectory == other.EnumerateDirectory);
            }
示例#2
0
        private EvaluationResult[] EnumerateFilesOrDirectories(
            Context context,
            string directoryPath,
            string searchPattern,
            uint directoriesToSkipRecursively,
            bool isRecursive,
            bool enumerateDirectory)
        {
            var enumeratePathKey = new EnumeratePathKey(directoryPath, searchPattern, isRecursive, enumerateDirectory);

            if (m_alreadyEnumeratedPaths.TryGetValue(enumeratePathKey, out var filesOrDirectories))
            {
                return(filesOrDirectories);
            }

            var accumulators = new DirectoryEntriesAccumulator(
                context,
                AbsolutePath.Create(context.PathTable, directoryPath),
                m_alreadyTrackedDirectories);

            var result = context.FrontEndContext.FileSystem.EnumerateDirectoryEntries(
                directoryPath,
                enumerateDirectory: enumerateDirectory,
                pattern: searchPattern,
                directoriesToSkipRecursively: directoriesToSkipRecursively,
                recursive: isRecursive,
                accumulators: accumulators);

            // If the result indicates that the enumeration succeeded or the directory does not exist, then the result is considered success.
            // In particular, if the globed directory does not exist, then we want to return the empty file, and track for the anti-dependency.
            if (
                !(result.Status == EnumerateDirectoryStatus.Success ||
                  result.Status == EnumerateDirectoryStatus.SearchDirectoryNotFound))
            {
                throw new DirectoryOperationException(result.Directory, result.CreateExceptionForError());
            }

            accumulators.Done();

            filesOrDirectories = accumulators.GetAndTrackArtifacts(asDirectories: enumerateDirectory);
            m_alreadyEnumeratedPaths.TryAdd(enumeratePathKey, filesOrDirectories);

            return(filesOrDirectories);
        }