@@ -170,6 +170,42 @@ static int Main(string[] args)
170
170
scriptDataParent . ReplaceChild ( scriptDecodedNode , scriptData [ 0 ] ) ;
171
171
licenseDataParent . ReplaceChild ( licenseDecodedNode , licenseData [ 0 ] ) ;
172
172
173
+ /* Find the File nodes */
174
+ XmlNodeList filesNodes = inputXMLdoc . SelectNodes ( "LabTech_Expansion/PackedScript/File" ) ;
175
+
176
+ /* Loop through the File nodes */
177
+ foreach ( XmlNode fileNode in filesNodes )
178
+ {
179
+ /* Don't touch invalid or empty File nodes */
180
+ if ( ! string . IsNullOrEmpty ( fileNode . Attributes [ "Bytes" ] . Value ) && ! string . IsNullOrEmpty ( fileNode . Attributes [ "Name" ] . Value ) )
181
+ {
182
+ /* Convert the Base 64 string to bytes */
183
+ byte [ ] filebytes = Convert . FromBase64String ( fileNode . Attributes [ "Bytes" ] . Value ) ;
184
+
185
+ /* Create the directory path if it doesn't exist */
186
+ if ( ! Directory . Exists ( Path . GetDirectoryName ( fileNode . Attributes [ "Name" ] . Value . Replace ( @"L:\" , @"C:\" ) ) ) )
187
+ {
188
+ Directory . CreateDirectory ( Path . GetDirectoryName ( fileNode . Attributes [ "Name" ] . Value . Replace ( @"L:\" , @"C:\" ) ) ) ;
189
+ }
190
+
191
+ /* If we're overwriting, then overwrite the existing files in the path */
192
+ if ( argOverwrite && File . Exists ( fileNode . Attributes [ "Name" ] . Value . Replace ( @"L:\" , @"C:\" ) ) )
193
+ {
194
+ File . Delete ( fileNode . Attributes [ "Name" ] . Value . Replace ( @"L:\" , @"C:\" ) ) ;
195
+ }
196
+
197
+ /* Create a filestream */
198
+ FileStream fs = new FileStream ( fileNode . Attributes [ "Name" ] . Value . Replace ( @"L:\" , @"C:\" ) ,
199
+ FileMode . CreateNew ,
200
+ FileAccess . Write ,
201
+ FileShare . None ) ;
202
+
203
+ /* Write the bytes to disk and close the file */
204
+ fs . Write ( filebytes , 0 , filebytes . Length ) ;
205
+ fs . Close ( ) ;
206
+ }
207
+ }
208
+
173
209
/* Create a new XMLdoc for output by copying the modified inputXML */
174
210
XmlDocument outputXMLdoc = new XmlDocument ( ) ;
175
211
outputXMLdoc = inputXMLdoc ;
0 commit comments