public IEnumerable <string> CopyFiles(string dest, NuGetCopySettings settings, CancellationToken token = default(CancellationToken)) { var files = GetFiles().Where(settings.Filter); var resultFiles = CopyFiles(dest, files, (source, target, readStream) => ExtractFile(source, target, dest, readStream, settings), _metadata.GetServer().Logger, token); dest.CleanDirectory(settings.RemoveEmptyFilter); return(resultFiles); }
private string ExtractFile(string source, string target, string dest, Stream readStream, NuGetCopySettings settings) { var destinationLessTarget = RemovePaths(target, dest); var alteredTarget = settings.PathAlter(destinationLessTarget).TrimStart('\\', '/'); target = Path.Combine(dest, alteredTarget); Directory.CreateDirectory(Path.GetDirectoryName(target)); if (Path.IsPathRooted(source)) { File.Copy(source, target, true); } else { using (var fileStream = new FileStream(target, FileMode.OpenOrCreate)) { readStream.CopyTo(fileStream); } } return(target); }