예제 #1
0
 internal static void AddFiles(this IFileSystem fileSystem, IEnumerable<IPackageFile> files, string rootDir)
 {
     foreach (IPackageFile file in files) {
         string path = Path.Combine(rootDir, file.Path);
         fileSystem.AddFileWithCheck(path, file.GetStream);
     }
 }
예제 #2
0
 /// <summary>
 /// Add the files to the specified FileSystem
 /// </summary>
 /// <param name="fileSystem">The file system.</param>
 /// <param name="files">The files to add to FileSystem.</param>
 /// <param name="rootDir">The directory of the FileSystem to copy the files to.</param>
 /// <param name="preserveFilePath">if set to <c>true</c> preserve full path of the copies files. Otherwise,
 /// all files with be copied to the <paramref name="rootDir"/>.</param>
 public static void AddFiles(this IFileSystem fileSystem, IEnumerable<IPackageFile> files, string rootDir, bool preserveFilePath)
 {
     foreach (IPackageFile file in files)
     {
         string path = Path.Combine(rootDir, preserveFilePath ? file.Path : Path.GetFileName(file.Path));
         fileSystem.AddFileWithCheck(path, file.GetStream);
     }
 }
예제 #3
0
 internal static void AddFileWithCheck(this IFileSystem fileSystem, string path, Action<Stream> write)
 {
     fileSystem.AddFileWithCheck(path, () => {
         var stream = new MemoryStream();
         write(stream);
         stream.Seek(0, SeekOrigin.Begin);
         return stream;
     });
 }