@joebigelow / wix-1 / commits / ce0fd262

Hide the ZipArchive details from the public WixOutput API

Rob Mensching committed Feb 26, 2020 at 11:30 UTC ce0fd262e48341402416c8428e37226c80332935
1 file changed +14 -3
src/WixToolset.Data/WixOutput.cs
+14 -3
@@ -13,8 +13,8 @@ namespace WixToolset.Data
13 /// </summary>
14 public class WixOutput : IDisposable
15 {
16 + private readonly Stream stream;
17 private ZipArchive archive;
17 - private Stream stream;
18 private bool disposed;
19
20 private WixOutput(Uri uri, ZipArchive archive, Stream stream)
@@ -140,10 +140,16 @@ namespace WixToolset.Data
140 }
141 }
142
143 - public void Reopen(ZipArchiveMode mode)
143 + /// <summary>
144 + /// Reopen the underlying archive for read-only or read-write access.
145 + /// </summary>
146 + /// <param name="writable">Indicates whether the output can be modified. Defaults to false.</param>
147 + public void Reopen(bool writable = false)
148 {
149 this.archive?.Dispose();
146 - this.archive = new ZipArchive(this.stream, mode, leaveOpen: true);
150 + this.archive = null;
151 +
152 + this.archive = new ZipArchive(this.stream, writable ? ZipArchiveMode.Update : ZipArchiveMode.Read, leaveOpen: true);
153 }
154
155 /// <summary>
@@ -178,6 +184,11 @@ namespace WixToolset.Data
184 return entry.Open();
185 }
186
187 + /// <summary>
188 + /// Imports a file from disk into the output.
189 + /// </summary>
190 + /// <param name="name">Name of the stream in the output.</param>
191 + /// <param name="path">Path to file on disk to include in the output.</param>
192 public void ImportDataStream(string name, string path)
193 {
194 this.archive.CreateEntryFromFile(path, name, System.IO.Compression.CompressionLevel.Optimal);