Skip to content

Commit f9b4e26

Browse files
committed
Update packages
1 parent 69f8d8c commit f9b4e26

File tree

18 files changed

+264
-294
lines changed

18 files changed

+264
-294
lines changed

BinaryObjectScanner.Test/BinaryObjectScanner.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>
1919
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
20-
<PackageReference Include="SabreTools.Serialization" Version="1.8.2" />
20+
<PackageReference Include="SabreTools.Serialization" Version="1.8.3" />
2121
<PackageReference Include="xunit" Version="2.9.2" />
2222
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

BinaryObjectScanner.Test/FactoryTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ public void CreateDetectableTests(WrapperType type, bool expectNull)
6868
WrapperType.GZIP,
6969
WrapperType.InstallShieldArchiveV3,
7070
WrapperType.InstallShieldCAB,
71+
WrapperType.LZKWAJ,
72+
WrapperType.LZQBasic,
73+
WrapperType.LZSZDD,
7174
WrapperType.MicrosoftCAB,
72-
WrapperType.MicrosoftLZ,
7375
WrapperType.MoPaQ,
7476
//WrapperType.N3DS,
7577
//WrapperType.NCF,

BinaryObjectScanner.Test/FileType/MicrosoftLZTests.cs renamed to BinaryObjectScanner.Test/FileType/LZKWAJTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace BinaryObjectScanner.Test.FileType
66
{
7-
public class MicrosoftLZTests
7+
public class LZKWAJTests
88
{
99
[Fact]
1010
public void ExtractFile_EmptyString_False()
1111
{
1212
string file = string.Empty;
1313
string outDir = string.Empty;
14-
var extractable = new MicrosoftLZ();
14+
var extractable = new LZKWAJ();
1515

1616
bool actual = extractable.Extract(file, outDir, includeDebug: false);
1717
Assert.False(actual);
@@ -23,7 +23,7 @@ public void ExtractStream_Null_False()
2323
Stream? stream = null;
2424
string file = string.Empty;
2525
string outDir = string.Empty;
26-
var extractable = new MicrosoftLZ();
26+
var extractable = new LZKWAJ();
2727

2828
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
2929
Assert.False(actual);
@@ -35,7 +35,7 @@ public void ExtractStream_Empty_False()
3535
Stream? stream = new MemoryStream();
3636
string file = string.Empty;
3737
string outDir = string.Empty;
38-
var extractable = new MicrosoftLZ();
38+
var extractable = new LZKWAJ();
3939

4040
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
4141
Assert.False(actual);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System.IO;
2+
using BinaryObjectScanner.FileType;
3+
using Xunit;
4+
5+
namespace BinaryObjectScanner.Test.FileType
6+
{
7+
public class LZQBasicTests
8+
{
9+
[Fact]
10+
public void ExtractFile_EmptyString_False()
11+
{
12+
string file = string.Empty;
13+
string outDir = string.Empty;
14+
var extractable = new LZQBasic();
15+
16+
bool actual = extractable.Extract(file, outDir, includeDebug: false);
17+
Assert.False(actual);
18+
}
19+
20+
[Fact]
21+
public void ExtractStream_Null_False()
22+
{
23+
Stream? stream = null;
24+
string file = string.Empty;
25+
string outDir = string.Empty;
26+
var extractable = new LZQBasic();
27+
28+
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
29+
Assert.False(actual);
30+
}
31+
32+
[Fact]
33+
public void ExtractStream_Empty_False()
34+
{
35+
Stream? stream = new MemoryStream();
36+
string file = string.Empty;
37+
string outDir = string.Empty;
38+
var extractable = new LZQBasic();
39+
40+
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
41+
Assert.False(actual);
42+
}
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System.IO;
2+
using BinaryObjectScanner.FileType;
3+
using Xunit;
4+
5+
namespace BinaryObjectScanner.Test.FileType
6+
{
7+
public class LZSZDDTests
8+
{
9+
[Fact]
10+
public void ExtractFile_EmptyString_False()
11+
{
12+
string file = string.Empty;
13+
string outDir = string.Empty;
14+
var extractable = new LZSZDD();
15+
16+
bool actual = extractable.Extract(file, outDir, includeDebug: false);
17+
Assert.False(actual);
18+
}
19+
20+
[Fact]
21+
public void ExtractStream_Null_False()
22+
{
23+
Stream? stream = null;
24+
string file = string.Empty;
25+
string outDir = string.Empty;
26+
var extractable = new LZSZDD();
27+
28+
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
29+
Assert.False(actual);
30+
}
31+
32+
[Fact]
33+
public void ExtractStream_Empty_False()
34+
{
35+
Stream? stream = new MemoryStream();
36+
string file = string.Empty;
37+
string outDir = string.Empty;
38+
var extractable = new LZSZDD();
39+
40+
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
41+
Assert.False(actual);
42+
}
43+
}
44+
}

BinaryObjectScanner.Test/FileType/SGATests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,5 @@ public void ExtractStream_Empty_False()
4040
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
4141
Assert.False(actual);
4242
}
43-
44-
[Fact]
45-
public void ExtractAll_EmptyModel_False()
46-
{
47-
var model = new SabreTools.Models.SGA.Archive();
48-
var data = new MemoryStream();
49-
var item = new SabreTools.Serialization.Wrappers.SGA(model, data);
50-
string outputDirectory = string.Empty;
51-
52-
bool actual = SGA.ExtractAll(item, outputDirectory);
53-
Assert.False(actual);
54-
}
55-
56-
[Fact]
57-
public void ExtractFile_EmptyModel_False()
58-
{
59-
var model = new SabreTools.Models.SGA.Archive();
60-
var data = new MemoryStream();
61-
var item = new SabreTools.Serialization.Wrappers.SGA(model, data);
62-
string outputDirectory = string.Empty;
63-
64-
bool actual = SGA.ExtractFile(item, 0, outputDirectory);
65-
Assert.False(actual);
66-
}
6743
}
6844
}

BinaryObjectScanner/BinaryObjectScanner.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@
8787
</ItemGroup>
8888

8989
<ItemGroup>
90-
<PackageReference Include="SabreTools.Compression" Version="0.6.1" />
90+
<PackageReference Include="SabreTools.Compression" Version="0.6.2" />
9191
<PackageReference Include="SabreTools.Hashing" Version="1.4.0" />
9292
<PackageReference Include="SabreTools.IO" Version="1.6.1" />
9393
<PackageReference Include="SabreTools.Matching" Version="1.5.0" />
94-
<PackageReference Include="SabreTools.Models" Version="1.5.6" />
95-
<PackageReference Include="SabreTools.Serialization" Version="1.8.2" />
96-
<PackageReference Include="UnshieldSharp" Version="1.9.2" />
97-
<PackageReference Include="WiseUnpacker" Version="1.5.4" />
94+
<PackageReference Include="SabreTools.Models" Version="1.5.7" />
95+
<PackageReference Include="SabreTools.Serialization" Version="1.8.3" />
96+
<PackageReference Include="UnshieldSharp" Version="1.9.3" />
97+
<PackageReference Include="WiseUnpacker" Version="1.5.5" />
9898
</ItemGroup>
9999

100100
</Project>

BinaryObjectScanner/Factory.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public static class Factory
4444
WrapperType.GZIP => new FileType.GZIP(),
4545
WrapperType.InstallShieldArchiveV3 => new FileType.InstallShieldArchiveV3(),
4646
WrapperType.InstallShieldCAB => new FileType.InstallShieldCAB(),
47+
WrapperType.LZKWAJ => new FileType.LZKWAJ(),
48+
WrapperType.LZQBasic => new FileType.LZQBasic(),
49+
WrapperType.LZSZDD => new FileType.LZSZDD(),
4750
WrapperType.MicrosoftCAB => new FileType.MicrosoftCAB(),
48-
WrapperType.MicrosoftLZ => new FileType.MicrosoftLZ(),
4951
WrapperType.MoPaQ => new FileType.MPQ(),
5052
//WrapperType.N3DS => new FileType.N3DS(),
5153
//WrapperType.NCF => new FileType.NCF(),
Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using System;
2-
using System.IO;
1+
using System.IO;
32
using BinaryObjectScanner.Interfaces;
4-
using ISv3 = UnshieldSharp.Archive.InstallShieldArchiveV3;
53

64
namespace 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
}

BinaryObjectScanner/FileType/InstallShieldCAB.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.IO;
33
using System.Text.RegularExpressions;
44
using BinaryObjectScanner.Interfaces;
5-
using UnshieldSharp.Cabinet;
5+
using UnshieldSharp;
66

77
namespace BinaryObjectScanner.FileType
88
{

0 commit comments

Comments
 (0)