@@ -25,7 +25,7 @@ private WixOutput(Uri uri, ZipArchive archive, Stream stream)
25
25
}
26
26
27
27
/// <summary>
28
- ///
28
+ ///
29
29
/// </summary>
30
30
public Uri Uri { get ; }
31
31
@@ -60,6 +60,24 @@ public static WixOutput Create(string path)
60
60
return WixOutput . Create ( uri , stream ) ;
61
61
}
62
62
63
+ /// <summary>
64
+ /// Creates a new file structure on disk that can only be written to.
65
+ /// </summary>
66
+ /// <param name="path">Path to write file structure to.</param>
67
+ /// <returns>Newly created <c>WixOutput</c>.</returns>
68
+ public static WixOutput CreateNew ( string path )
69
+ {
70
+ var fullPath = Path . GetFullPath ( path ) ;
71
+
72
+ Directory . CreateDirectory ( Path . GetDirectoryName ( fullPath ) ) ;
73
+
74
+ var uri = new Uri ( fullPath ) ;
75
+
76
+ var stream = File . Create ( path ) ;
77
+
78
+ return WixOutput . CreateNew ( uri , stream ) ;
79
+ }
80
+
63
81
/// <summary>
64
82
/// Creates a new file structure.
65
83
/// </summary>
@@ -73,6 +91,19 @@ public static WixOutput Create(Uri uri, Stream stream)
73
91
return new WixOutput ( uri , archive , stream ) ;
74
92
}
75
93
94
+ /// <summary>
95
+ /// Creates a new file structure that can only be written to.
96
+ /// </summary>
97
+ /// <param name="uri"></param>
98
+ /// <param name="stream">Stream to write the file structure to.</param>
99
+ /// <returns>Newly created <c>WixOutput</c>.</returns>
100
+ public static WixOutput CreateNew ( Uri uri , Stream stream )
101
+ {
102
+ var archive = new ZipArchive ( stream , ZipArchiveMode . Create , leaveOpen : true ) ;
103
+
104
+ return new WixOutput ( uri , archive , stream ) ;
105
+ }
106
+
76
107
/// <summary>
77
108
/// Loads a wixout from a path on disk.
78
109
/// </summary>
@@ -189,7 +220,10 @@ public void ExtractEmbeddedFile(string embeddedId, string outputPath)
189
220
/// <returns>Stream to the data of the file.</returns>
190
221
public Stream CreateDataStream ( string name )
191
222
{
192
- this . DeleteExistingEntry ( name ) ;
223
+ if ( this . archive . Mode == ZipArchiveMode . Update )
224
+ {
225
+ this . DeleteExistingEntry ( name ) ;
226
+ }
193
227
194
228
var entry = this . archive . CreateEntry ( name ) ;
195
229
@@ -203,7 +237,10 @@ public Stream CreateDataStream(string name)
203
237
/// <param name="path">Path to file on disk to include in the output.</param>
204
238
public void ImportDataStream ( string name , string path )
205
239
{
206
- this . DeleteExistingEntry ( name ) ;
240
+ if ( this . archive . Mode == ZipArchiveMode . Update )
241
+ {
242
+ this . DeleteExistingEntry ( name ) ;
243
+ }
207
244
208
245
this . archive . CreateEntryFromFile ( path , name , System . IO . Compression . CompressionLevel . Optimal ) ;
209
246
}
0 commit comments