@@ -25,7 +25,7 @@ private WixOutput(Uri uri, ZipArchive archive, Stream stream)
2525 }
2626
2727 /// <summary>
28- ///
28+ ///
2929 /// </summary>
3030 public Uri Uri { get ; }
3131
@@ -189,7 +189,10 @@ public void ExtractEmbeddedFile(string embeddedId, string outputPath)
189189 /// <returns>Stream to the data of the file.</returns>
190190 public Stream CreateDataStream ( string name )
191191 {
192- this . DeleteExistingEntry ( name ) ;
192+ if ( this . archive . Mode == ZipArchiveMode . Update )
193+ {
194+ this . DeleteExistingEntry ( name ) ;
195+ }
193196
194197 var entry = this . archive . CreateEntry ( name ) ;
195198
@@ -203,7 +206,10 @@ public Stream CreateDataStream(string name)
203206 /// <param name="path">Path to file on disk to include in the output.</param>
204207 public void ImportDataStream ( string name , string path )
205208 {
206- this . DeleteExistingEntry ( name ) ;
209+ if ( this . archive . Mode == ZipArchiveMode . Update )
210+ {
211+ this . DeleteExistingEntry ( name ) ;
212+ }
207213
208214 this . archive . CreateEntryFromFile ( path , name , System . IO . Compression . CompressionLevel . Optimal ) ;
209215 }
@@ -240,6 +246,26 @@ public string GetData(string name)
240246 }
241247 }
242248
249+ /// <summary>
250+ /// Creates a new file structure on disk that can only be written to.
251+ /// </summary>
252+ /// <param name="path">Path to write file structure to.</param>
253+ /// <returns>Newly created <c>WixOutput</c>.</returns>
254+ internal static WixOutput CreateNew ( string path )
255+ {
256+ var fullPath = Path . GetFullPath ( path ) ;
257+
258+ Directory . CreateDirectory ( Path . GetDirectoryName ( fullPath ) ) ;
259+
260+ var uri = new Uri ( fullPath ) ;
261+
262+ var stream = File . Create ( path ) ;
263+
264+ var archive = new ZipArchive ( stream , ZipArchiveMode . Create , leaveOpen : true ) ;
265+
266+ return new WixOutput ( uri , archive , stream ) ;
267+ }
268+
243269 /// <summary>
244270 /// Disposes of the internal state of the file structure.
245271 /// </summary>
0 commit comments