1- using System ;
2- using System . IO ;
1+ using System . IO ;
32using BinaryObjectScanner . Interfaces ;
4- using ISv3 = UnshieldSharp . Archive . InstallShieldArchiveV3 ;
53
64namespace BinaryObjectScanner . FileType
75{
@@ -23,41 +21,16 @@ public bool Extract(string file, string outDir, bool includeDebug)
2321 /// <inheritdoc/>
2422 public bool Extract ( Stream ? stream , string file , string outDir , bool includeDebug )
2523 {
26- try
27- {
28- if ( ! File . Exists ( file ) )
29- return false ;
30-
31- var archive = new ISv3 ( file ) ;
32- foreach ( var cfile in archive . Files )
33- {
34- try
35- {
36- string tempFile = Path . Combine ( outDir , cfile . Key ) ;
37- var directoryName = Path . GetDirectoryName ( tempFile ) ;
38- if ( directoryName != null && ! Directory . Exists ( directoryName ) )
39- Directory . CreateDirectory ( directoryName ) ;
40-
41- byte [ ] ? fileContents = archive . Extract ( cfile . Key , out string ? error ) ;
42- if ( fileContents == null || ! string . IsNullOrEmpty ( error ) )
43- continue ;
24+ // Create the wrapper
25+ var isv3 = SabreTools . Serialization . Wrappers . InstallShieldArchiveV3 . Create ( stream ) ;
26+ if ( isv3 == null )
27+ return false ;
4428
45- using FileStream fs = File . OpenWrite ( tempFile ) ;
46- fs . Write ( fileContents , 0 , fileContents . Length ) ;
47- }
48- catch ( Exception ex )
49- {
50- if ( includeDebug ) Console . WriteLine ( ex ) ;
51- }
52- }
29+ // Loop through and extract all files
30+ Directory . CreateDirectory ( outDir ) ;
31+ isv3 . ExtractAll ( outDir ) ;
5332
54- return true ;
55- }
56- catch ( Exception ex )
57- {
58- if ( includeDebug ) Console . WriteLine ( ex ) ;
59- return false ;
60- }
33+ return true ;
6134 }
6235 }
6336}
0 commit comments