示例#1
0
        private void CollectExternalFilesForDirectory(ExternalFiles externalFiles, FileSystemPath directory)
        {
            // Don't process the entire solution directory - this would process Assets and Packages for a second time,
            // and also process Temp and Library, which are likely to be huge
            if (directory == mySolutionDirectory)
            {
                myLogger.Error("Unexpected request to process entire solution directory. Skipping");
                return;
            }

            if (myRootPaths.Contains(directory))
            {
                return;
            }

            // Make sure the directory hasn't already been processed as part of a previous directory. This can happen if
            // the project is a .asmdef based project living under Assets or Packages, or inside a file:// based package
            foreach (var rootPath in myRootPaths)
            {
                if (rootPath.IsPrefixOf(directory))
                {
                    return;
                }
            }

            myLogger.Info("Processing directory for asset and meta files: {0}", directory);

            // Based on super simple tests, GetDirectoryEntries is faster than GetChildFiles with subsequent calls to
            // GetFileLength. But what is more surprising is that Windows in a VM is an order of magnitude FASTER than
            // Mac, on the same project!
            var entries = directory.GetDirectoryEntries("*", PathSearchFlags.RecurseIntoSubdirectories
                                                        | PathSearchFlags.ExcludeDirectories);

            foreach (var entry in entries)
            {
                externalFiles.AddFile(entry);
            }
            externalFiles.AddDirectory(directory);

            myRootPaths.Add(directory);
        }