Minor tweaks from issues found during extraction

This commit is contained in:
Matt Nadareski
2023-01-03 10:42:57 -08:00
parent 2416a035c7
commit b07fd29753
4 changed files with 20 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ namespace BurnOutSharp.Builders
// Read all entries in turn
for (int i = 0; i < header.FileCount; i++)
{
var file = ParseFileDescriptor(data);
var file = ParseFileDescriptor(data, header.MinorVersion);
if (file == null)
return null;
@@ -91,6 +91,9 @@ namespace BurnOutSharp.Builders
#endregion
// Cache the compressed data offset
archive.CompressedDataOffset = data.Position;
return archive;
}
@@ -122,8 +125,9 @@ namespace BurnOutSharp.Builders
/// Parse a Stream into a file descriptor
/// </summary>
/// <param name="data">Stream to parse</param>
/// <param name="minorVersion">Minor version of the archive</param>
/// <returns>Filled file descriptor on success, null on error</returns>
private static FileDescriptor ParseFileDescriptor(Stream data)
private static FileDescriptor ParseFileDescriptor(Stream data, byte minorVersion)
{
// TODO: Use marshalling here instead of building
FileDescriptor fileDescriptor = new FileDescriptor();
@@ -146,6 +150,10 @@ namespace BurnOutSharp.Builders
fileDescriptor.FileTime = data.ReadUInt16();
fileDescriptor.FileDate = data.ReadUInt16();
// Hack for unknown format data
if (minorVersion == 22)
_ = data.ReadUInt16();
return fileDescriptor;
}

View File

@@ -142,7 +142,7 @@ namespace BurnOutSharp.Compression.Quantum
}
}
if (togo != 0)
if (togo > 0)
return false;
Array.Copy(state.Window, (windowPosition == 0 ? windowSize : windowPosition) - outlen, outbuf, 0, outlen);

View File

@@ -16,6 +16,9 @@ namespace BurnOutSharp.Models.Quantum
/// </summary>
public FileDescriptor[] FileList { get; set; }
// Immediately following the list of files is the compressed data.
/// <summary>
/// Immediately following the list of files is the compressed data
/// </summary>
public long CompressedDataOffset { get; set; }
}
}

View File

@@ -1,7 +1,5 @@
using System;
using System.IO;
using SharpCompress.Compressors;
using SharpCompress.Compressors.Deflate;
namespace BurnOutSharp.Wrappers
{
@@ -38,6 +36,9 @@ namespace BurnOutSharp.Wrappers
#endregion
/// <inheritdoc cref="Models.Quantum.Archive.CompressedDataOffset"/>
public long CompressedDataOffset => _archive.CompressedDataOffset;
#endregion
#region Instance Variables
@@ -162,6 +163,8 @@ namespace BurnOutSharp.Wrappers
PrintHeader();
PrintFileList();
Console.WriteLine($" Compressed data offset: {CompressedDataOffset}");
Console.WriteLine();
}
/// <summary>