Skip to content

Commit 94cb06a

Browse files
committed
Handle some messages
1 parent 907aea4 commit 94cb06a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1497
-1677
lines changed

BinaryObjectScanner/FileType/BFPK.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class BFPK : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>
@@ -111,18 +109,18 @@ public static bool ExtractFile(SabreTools.Serialization.Wrappers.BFPK item, int
111109

112110
// Create the output path
113111
string filePath = Path.Combine(outputDirectory, file.Name ?? $"file{index}");
114-
using (FileStream fs = File.OpenWrite(filePath))
115-
{
116-
// Read the data block
117-
var data = item.ReadFromDataSource(offset, compressedSize);
118-
if (data == null)
119-
return false;
112+
using FileStream fs = File.OpenWrite(filePath);
120113

121-
// If we have uncompressed data
122-
if (compressedSize == file.UncompressedSize)
123-
{
124-
fs.Write(data, 0, compressedSize);
125-
}
114+
// Read the data block
115+
var data = item.ReadFromDataSource(offset, compressedSize);
116+
if (data == null)
117+
return false;
118+
119+
// If we have uncompressed data
120+
if (compressedSize == file.UncompressedSize)
121+
{
122+
fs.Write(data, 0, compressedSize);
123+
}
126124
#if NET462_OR_GREATER || NETCOREAPP
127125
else
128126
{
@@ -131,7 +129,6 @@ public static bool ExtractFile(SabreTools.Serialization.Wrappers.BFPK item, int
131129
zs.CopyTo(fs);
132130
}
133131
#endif
134-
}
135132

136133
return true;
137134
}

BinaryObjectScanner/FileType/BZip2.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class BZip2 : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>

BinaryObjectScanner/FileType/GZIP.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class GZIP : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>

BinaryObjectScanner/FileType/PKZIP.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class PKZIP : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>

BinaryObjectScanner/FileType/RAR.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class RAR : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>

BinaryObjectScanner/FileType/SGA.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ public class SGA : IExtractable
2020
if (!File.Exists(file))
2121
return null;
2222

23-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
24-
{
25-
return Extract(fs, file, includeDebug);
26-
}
23+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
24+
return Extract(fs, file, includeDebug);
2725
}
2826

2927
/// <inheritdoc/>
@@ -259,10 +257,8 @@ public static bool ExtractFile(SabreTools.Serialization.Wrappers.SGA item, int i
259257
try
260258
{
261259
// Open the output file for writing
262-
using (Stream fs = File.OpenWrite(filename))
263-
{
264-
fs.Write(data, 0, data.Length);
265-
}
260+
using Stream fs = File.OpenWrite(filename);
261+
fs.Write(data, 0, data.Length);
266262
}
267263
catch
268264
{

BinaryObjectScanner/FileType/SevenZip.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class SevenZip : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>

BinaryObjectScanner/FileType/TapeArchive.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class TapeArchive : IExtractable
1919
if (!File.Exists(file))
2020
return null;
2121

22-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
23-
{
24-
return Extract(fs, file, includeDebug);
25-
}
22+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
23+
return Extract(fs, file, includeDebug);
2624
}
2725

2826
/// <inheritdoc/>

BinaryObjectScanner/FileType/XZ.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ public class XZ : IExtractable
1818
if (!File.Exists(file))
1919
return null;
2020

21-
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
22-
{
23-
return Extract(fs, file, includeDebug);
24-
}
21+
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
22+
return Extract(fs, file, includeDebug);
2523
}
2624

2725
/// <inheritdoc/>

BinaryObjectScanner/Handler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public static IEnumerable<IPathCheck?> PathCheckClasses
2424
{
2525
get
2626
{
27-
if (pathCheckClasses == null)
28-
pathCheckClasses = InitCheckClasses<IPathCheck>();
29-
27+
pathCheckClasses ??= InitCheckClasses<IPathCheck>();
3028
return pathCheckClasses;
3129
}
3230
}

0 commit comments

Comments
 (0)