mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-22 06:45:11 +00:00
Normalize ReadRangeFromSource use
This commit is contained in:
@@ -82,7 +82,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read the data block
|
||||
var data = ReadRangeFromSource(offset, compressedSize);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have uncompressed data
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Read the data
|
||||
var lump = Lumps[index];
|
||||
var data = ReadRangeFromSource(lump.Offset, lump.Length);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// Create the filename
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Try to read the sector data
|
||||
var sectorData = ReadRangeFromSource(sectorDataOffset, (int)SectorSize);
|
||||
if (sectorData == null)
|
||||
if (sectorData.Length == 0)
|
||||
return null;
|
||||
|
||||
// Add the sector data to the output
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
int readSize = (int)Math.Min(BlockSize, fileSize);
|
||||
var data = ReadRangeFromSource((int)dataBlockOffsets[i], readSize);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
fs.Write(data, 0, data.Length);
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read the compressed data directly
|
||||
var compressedData = ReadRangeFromSource((int)fileOffset, (int)fileSize);
|
||||
if (compressedData == null)
|
||||
if (compressedData.Length == 0)
|
||||
return false;
|
||||
|
||||
// If the compressed and uncompressed sizes match
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read in the data as an array
|
||||
byte[]? contents = ReadRangeFromSource(DataOffset, (int)compressedSize);
|
||||
if (contents == null)
|
||||
if (contents.Length == 0)
|
||||
return false;
|
||||
|
||||
// Get the decompressor
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read in the data as an array
|
||||
byte[]? contents = ReadRangeFromSource(12, (int)compressedSize);
|
||||
if (contents == null)
|
||||
if (contents.Length == 0)
|
||||
return false;
|
||||
|
||||
// Get the decompressor
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read in the data as an array
|
||||
byte[]? contents = ReadRangeFromSource(14, (int)compressedSize);
|
||||
if (contents == null)
|
||||
if (contents.Length == 0)
|
||||
return false;
|
||||
|
||||
// Get the decompressor
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Read the item data
|
||||
var directoryItem = DirectoryItems[index];
|
||||
var data = ReadRangeFromSource((int)directoryItem.ItemOffset, (int)directoryItem.ItemLength);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid output directory
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read the data block
|
||||
var data = ReadRangeFromSource(offset, size);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// Write the data -- TODO: Compressed data?
|
||||
|
||||
@@ -1173,7 +1173,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
try
|
||||
{
|
||||
entryData = ReadRangeFromSource((int)address, (int)size);
|
||||
if (entryData == null || entryData.Length < 4)
|
||||
if (entryData.Length < 4)
|
||||
continue;
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
@@ -1871,10 +1871,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return _sectionData[index];
|
||||
|
||||
// Populate the raw section data based on the source
|
||||
byte[]? sectionData = ReadRangeFromSource((int)address, (int)size);
|
||||
var sectionData = ReadRangeFromSource((int)address, (int)size);
|
||||
|
||||
// Cache and return the section data, even if null
|
||||
_sectionData[index] = sectionData ?? [];
|
||||
// Cache and return the section data
|
||||
_sectionData[index] = sectionData;
|
||||
return sectionData;
|
||||
}
|
||||
|
||||
@@ -2032,10 +2032,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return null;
|
||||
|
||||
// Populate the raw table data based on the source
|
||||
byte[]? tableData = ReadRangeFromSource((int)address, (int)size);
|
||||
var tableData = ReadRangeFromSource((int)address, (int)size);
|
||||
|
||||
// Cache and return the table data, even if null
|
||||
_tableData[index] = tableData ?? [];
|
||||
// Cache and return the table data
|
||||
_tableData[index] = tableData;
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Read the compressed data directly
|
||||
var compressedData = ReadRangeFromSource((int)fileOffset, (int)fileSize);
|
||||
if (compressedData == null)
|
||||
if (compressedData.Length == 0)
|
||||
return false;
|
||||
|
||||
// If the compressed and uncompressed sizes match
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Read the data
|
||||
var lump = Lumps[index];
|
||||
var data = ReadRangeFromSource(lump.Offset, lump.Length);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid output directory
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Read the data -- TODO: Handle uncompressed lumps (see BSP.ExtractTexture)
|
||||
var lump = DirEntries[index];
|
||||
var data = ReadRangeFromSource((int)lump.Offset, (int)lump.Length);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid output directory
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Load the item data
|
||||
var data = ReadRangeFromSource((int)directoryEntry.EntryOffset, (int)directoryEntry.EntryLength);
|
||||
if (data == null)
|
||||
if (data.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid output directory
|
||||
|
||||
Reference in New Issue
Block a user