Bari.Core.Build.Cache.FileBuildCache.SaveOutputs C# (CSharp) Method

SaveOutputs() private method

Copies output files to the cache directory, and also saves a '.names' file referring to he original target relative paths of these files.
private SaveOutputs ( IEnumerable outputs, IFileSystemDirectory targetRoot, IFileSystemDirectory cacheDir ) : void
outputs IEnumerable Build outputs to be copied
targetRoot IFileSystemDirectory Root directory for the build outputs
cacheDir IFileSystemDirectory Target directory for the copy operation
return void
        private void SaveOutputs(IEnumerable<TargetRelativePath> outputs, IFileSystemDirectory targetRoot, IFileSystemDirectory cacheDir)
        {
            using (var names = cacheDir.CreateTextFile(NamesFileName))
            {
                int idx = 0;
                foreach (var outputPath in outputs)
                {
                    try
                    {
                        // It is possible that the returned path is a special path and does not refer to an existing file
                        // In this case we only have to save the filename, without its contents
                        if (targetRoot.Exists(outputPath))
                        {
                            targetRoot.CopyFile(outputPath, cacheDir, idx.ToString(CultureInfo.InvariantCulture));
                        }

                        names.WriteLine("{0};{1}", outputPath.RelativeRoot, outputPath.RelativePath);
                        idx++;
                    }
                    catch (IOException ex)
                    {
                        log.WarnFormat("IOException while reading {0}: {1}", outputPath, ex.Message);

                        if (!outputPath.RelativePath.ToLowerInvariant().EndsWith(".vshost.exe"))
                            throw;
                    }
                }
            }
        }