Skip to content

Commit 28b2eaa

Browse files
committed
Fix assumption about MS-CAB sets
1 parent 0585f0a commit 28b2eaa

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

BinaryObjectScanner/FileType/MicrosoftCAB.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ public bool Extract(Stream? stream, string file, string outDir, bool includeDebu
142142
/// <param name="filename">Filename for one cabinet in the set, if available</param>
143143
/// <param name="outDir">Path to the output directory</param>
144144
/// <param name="includeDebug">True to include debug data, false otherwise</param>
145-
/// <param name="forwardOnly">Indicates if decompression should be done forward-only</param>
146145
/// <returns>Indicates if all files were able to be extracted</returns>
147146
/// TODO: Remove once Serialization is updated
148147
private static bool ExtractCabinet(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive, string? filename, string outDir, bool forwardOnly, bool includeDebug)
@@ -157,7 +156,7 @@ private static bool ExtractCabinet(SabreTools.Serialization.Wrappers.MicrosoftCa
157156
for (int f = 0; f < cabArchive.Model.Folders.Length; f++)
158157
{
159158
var folder = cabArchive.Model.Folders[f];
160-
ExtractFolder(cabArchive, filename, outDir, folder, f, forwardOnly, includeDebug);
159+
ExtractFolder(cabArchive, filename, outDir, folder, f, includeDebug);
161160
}
162161

163162
return true;
@@ -176,19 +175,17 @@ private static bool ExtractCabinet(SabreTools.Serialization.Wrappers.MicrosoftCa
176175
/// <param name="outDir">Path to the output directory</param>
177176
/// <param name="folder">Folder containing the blocks to decompress</param>
178177
/// <param name="folderIndex">Index of the folder in the cabinet</param>
179-
/// <param name="forwardOnly">Indicates if decompression should be done forward-only</param>
180178
/// <param name="includeDebug">True to include debug data, false otherwise</param>
181179
/// TODO: Remove once Serialization is updated
182180
private static void ExtractFolder(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive,
183181
string? filename,
184182
string outDir,
185183
CFFOLDER? folder,
186184
int folderIndex,
187-
bool forwardOnly,
188185
bool includeDebug)
189186
{
190187
// Decompress the blocks, if possible
191-
using var blockStream = DecompressBlocks(cabArchive, filename, folder, folderIndex, forwardOnly);
188+
using var blockStream = DecompressBlocks(cabArchive, filename, folder, folderIndex);
192189
if (blockStream == null || blockStream.Length == 0)
193190
return;
194191

@@ -235,15 +232,12 @@ private static void ExtractFolder(SabreTools.Serialization.Wrappers.MicrosoftCab
235232
/// <param name="filename">Filename for one cabinet in the set, if available</param>
236233
/// <param name="folder">Folder containing the blocks to decompress</param>
237234
/// <param name="folderIndex">Index of the folder in the cabinet</param>
238-
/// <param name="forwardOnly">Indicates if decompression should be done forward-only</param>
239235
/// <returns>Stream representing the decompressed data on success, null otherwise</returns>
240236
/// TODO: Remove once Serialization is updated
241-
private static Stream? DecompressBlocks(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive, string? filename, CFFOLDER? folder, int folderIndex, bool forwardOnly)
237+
private static Stream? DecompressBlocks(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive, string? filename, CFFOLDER? folder, int folderIndex)
242238
{
243239
// Ensure data blocks
244-
var dataBlocks = forwardOnly
245-
? GetDataBlocksForward(cabArchive, filename, folder, folderIndex)
246-
: GetDataBlocks(cabArchive, filename, folder, folderIndex);
240+
var dataBlocks = GetDataBlocks(cabArchive, filename, folder, folderIndex);
247241
if (dataBlocks == null || dataBlocks.Length == 0)
248242
return null;
249243

@@ -375,17 +369,6 @@ private static CompressionType GetCompressionType(CFFOLDER folder)
375369
return [.. prevBlocks, .. folder.DataBlocks, .. nextBlocks];
376370
}
377371

378-
/// <summary>
379-
/// Get the set of data blocks for a folder using forward reading only
380-
/// </summary>
381-
/// <param name="filename">Filename for one cabinet in the set, if available</param>
382-
/// <param name="folder">Folder containing the blocks to decompress</param>
383-
/// <param name="folderIndex">Index of the folder in the cabinet</param>
384-
/// <returns>Array of data blocks on success, null otherwise</returns>
385-
/// TODO: Remove once Serialization is updated
386-
private static CFDATA[]? GetDataBlocksForward(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive, string? filename, CFFOLDER? folder, int folderIndex)
387-
=> GetDataBlocks(cabArchive, filename, folder, folderIndex, skipPrev: true, skipNext: false);
388-
389372
/// <summary>
390373
/// Get all files for the current folder index
391374
/// </summary>

0 commit comments

Comments
 (0)