Convert some known Peek calls

This commit is contained in:
Matt Nadareski
2025-10-27 22:55:25 -04:00
parent ce394eb4e9
commit db1f94775b
4 changed files with 4 additions and 8 deletions

View File

@@ -31,8 +31,7 @@ namespace SabreTools.Serialization.Readers
#region User Data
// Check for User Data
uint possibleSignature = data.ReadUInt32LittleEndian();
data.SeekIfPossible(-4, SeekOrigin.Current);
uint possibleSignature = data.PeekUInt32LittleEndian();
if (possibleSignature == UserDataSignatureUInt32)
{
// Deserialize the user data, returning null if invalid

View File

@@ -133,9 +133,8 @@ namespace SabreTools.Serialization.Readers
return obj;
// Peek at the next 5 bytes
byte[] temp = data.ReadBytes(5);
byte[] temp = data.PeekBytes(5);
string tempString = Encoding.ASCII.GetString(temp);
data.SeekIfPossible(-5, SeekOrigin.Current);
if (tempString != "ustar")
return obj;

View File

@@ -124,8 +124,7 @@ namespace SabreTools.Serialization.Readers
obj.DibInflatedSize = data.ReadUInt32LittleEndian();
// Peek at the next 2 bytes
ushort peek = data.ReadUInt16LittleEndian();
data.SeekIfPossible(-2, SeekOrigin.Current);
ushort peek = data.PeekUInt16LittleEndian();
// If the next value is a known Endianness
if (Enum.IsDefined(typeof(Endianness), peek))

View File

@@ -561,8 +561,7 @@ namespace SabreTools.Serialization.Readers
}
// Check for an empty registry call
uint possiblyEmpty = data.ReadUInt32LittleEndian();
data.SeekIfPossible(-4, SeekOrigin.Current);
uint possiblyEmpty = data.PeekUInt32LittleEndian();
if (possiblyEmpty == 0x00000000)
{
obj.DataType = data.ReadByteValue();