Skip to content

Commit 4d2700a

Browse files
initial
1 parent f51cfeb commit 4d2700a

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

SabreTools.Serialization/Readers/MicrosoftCabinet.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ private static CFDATA ParseDataBlock(Stream data, byte dataReservedSize)
204204
dataBlock.CompressedSize = data.ReadUInt16LittleEndian();
205205
dataBlock.UncompressedSize = data.ReadUInt16LittleEndian();
206206

207-
if (dataReservedSize > 0)
208-
dataBlock.ReservedData = data.ReadBytes(dataReservedSize);
209-
210-
if (dataBlock.CompressedSize > 0)
211-
dataBlock.CompressedData = data.ReadBytes(dataBlock.CompressedSize);
212-
213207
return dataBlock;
214208
}
215209

SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,32 @@ public bool Extract(string outputDirectory, bool includeDebug)
198198
}
199199
}
200200

201+
public void GetData(CFFOLDER folder)
202+
{
203+
if (folder.CabStartOffset > 0)
204+
{
205+
uint offset = folder.CabStartOffset;
206+
207+
for (int i = 0; i < folder.DataCount; i++)
208+
{
209+
offset += 8;
210+
211+
if (Header.DataReservedSize > 0)
212+
{
213+
folder.DataBlocks[i].ReservedData = ReadRangeFromSource(offset, Header.DataReservedSize);
214+
offset += Header.DataReservedSize;
215+
}
216+
217+
if (folder.DataBlocks[i].CompressedSize > 0)
218+
{
219+
folder.DataBlocks[i].CompressedData = ReadRangeFromSource(offset, folder.DataBlocks[i].CompressedSize);
220+
offset += folder.DataBlocks[i].CompressedSize;
221+
}
222+
}
223+
}
224+
}
225+
226+
201227
/// <summary>
202228
/// Extract the contents of a single folder
203229
/// </summary>

SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ private static CompressionType GetCompressionType(CFFOLDER folder)
315315
if (folder?.DataBlocks == null || folder.DataBlocks.Length == 0)
316316
return null;
317317

318+
GetData(folder);
319+
318320
// Get all files for the folder
319321
var files = GetFiles(folderIndex);
320322
if (files.Length == 0)

0 commit comments

Comments
 (0)