mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Refactor Read and Write classes to use ReadOnlySpan for tape entries.
This commit is contained in:
@@ -1166,7 +1166,7 @@ public sealed partial class AaruFormat
|
|||||||
byte[] tapePartitionBytes = new byte[partitionHeader.length];
|
byte[] tapePartitionBytes = new byte[partitionHeader.length];
|
||||||
_imageStream.EnsureRead(tapePartitionBytes, 0, tapePartitionBytes.Length);
|
_imageStream.EnsureRead(tapePartitionBytes, 0, tapePartitionBytes.Length);
|
||||||
|
|
||||||
Span<TapePartitionEntry> tapePartitions =
|
ReadOnlySpan<TapePartitionEntry> tapePartitions =
|
||||||
MemoryMarshal.Cast<byte, TapePartitionEntry>(tapePartitionBytes);
|
MemoryMarshal.Cast<byte, TapePartitionEntry>(tapePartitionBytes);
|
||||||
|
|
||||||
TapePartitions = [];
|
TapePartitions = [];
|
||||||
@@ -1198,7 +1198,7 @@ public sealed partial class AaruFormat
|
|||||||
|
|
||||||
byte[] tapeFileBytes = new byte[fileHeader.length];
|
byte[] tapeFileBytes = new byte[fileHeader.length];
|
||||||
_imageStream.EnsureRead(tapeFileBytes, 0, tapeFileBytes.Length);
|
_imageStream.EnsureRead(tapeFileBytes, 0, tapeFileBytes.Length);
|
||||||
Span<TapeFileEntry> tapeFiles = MemoryMarshal.Cast<byte, TapeFileEntry>(tapeFileBytes);
|
ReadOnlySpan<TapeFileEntry> tapeFiles = MemoryMarshal.Cast<byte, TapeFileEntry>(tapeFileBytes);
|
||||||
Files = [];
|
Files = [];
|
||||||
|
|
||||||
foreach(TapeFileEntry file in tapeFiles)
|
foreach(TapeFileEntry file in tapeFiles)
|
||||||
|
|||||||
@@ -1361,7 +1361,7 @@ public sealed partial class AaruFormat
|
|||||||
byte[] tapePartitionBytes = new byte[partitionHeader.length];
|
byte[] tapePartitionBytes = new byte[partitionHeader.length];
|
||||||
_imageStream.EnsureRead(tapePartitionBytes, 0, tapePartitionBytes.Length);
|
_imageStream.EnsureRead(tapePartitionBytes, 0, tapePartitionBytes.Length);
|
||||||
|
|
||||||
Span<TapePartitionEntry> tapePartitions =
|
ReadOnlySpan<TapePartitionEntry> tapePartitions =
|
||||||
MemoryMarshal.Cast<byte, TapePartitionEntry>(tapePartitionBytes);
|
MemoryMarshal.Cast<byte, TapePartitionEntry>(tapePartitionBytes);
|
||||||
|
|
||||||
TapePartitions = [];
|
TapePartitions = [];
|
||||||
@@ -1394,7 +1394,7 @@ public sealed partial class AaruFormat
|
|||||||
|
|
||||||
byte[] tapeFileBytes = new byte[fileHeader.length];
|
byte[] tapeFileBytes = new byte[fileHeader.length];
|
||||||
_imageStream.EnsureRead(tapeFileBytes, 0, tapeFileBytes.Length);
|
_imageStream.EnsureRead(tapeFileBytes, 0, tapeFileBytes.Length);
|
||||||
Span<TapeFileEntry> tapeFiles = MemoryMarshal.Cast<byte, TapeFileEntry>(tapeFileBytes);
|
ReadOnlySpan<TapeFileEntry> tapeFiles = MemoryMarshal.Cast<byte, TapeFileEntry>(tapeFileBytes);
|
||||||
Files = [];
|
Files = [];
|
||||||
|
|
||||||
foreach(TapeFileEntry file in tapeFiles)
|
foreach(TapeFileEntry file in tapeFiles)
|
||||||
@@ -1899,8 +1899,9 @@ public sealed partial class AaruFormat
|
|||||||
|
|
||||||
// Fill FLAC block
|
// Fill FLAC block
|
||||||
if(remaining != 0)
|
if(remaining != 0)
|
||||||
for(int r = 0; r < remaining * 4; r++)
|
{
|
||||||
_writingBuffer[_writingBufferPosition + r] = 0;
|
for(int r = 0; r < remaining * 4; r++) _writingBuffer[_writingBufferPosition + r] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
compressedLength = FLAC.EncodeBuffer(_writingBuffer,
|
compressedLength = FLAC.EncodeBuffer(_writingBuffer,
|
||||||
_compressedBuffer,
|
_compressedBuffer,
|
||||||
@@ -2692,8 +2693,9 @@ public sealed partial class AaruFormat
|
|||||||
|
|
||||||
// Fill FLAC block
|
// Fill FLAC block
|
||||||
if(remaining != 0)
|
if(remaining != 0)
|
||||||
for(int r = 0; r < remaining * 4; r++)
|
{
|
||||||
_writingBuffer[_writingBufferPosition + r] = 0;
|
for(int r = 0; r < remaining * 4; r++) _writingBuffer[_writingBufferPosition + r] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
compressedLength = FLAC.EncodeBuffer(_writingBuffer,
|
compressedLength = FLAC.EncodeBuffer(_writingBuffer,
|
||||||
_compressedBuffer,
|
_compressedBuffer,
|
||||||
|
|||||||
@@ -166,12 +166,12 @@ public sealed partial class VMware
|
|||||||
};
|
};
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME,
|
||||||
"{0} {1} {2} \"{3}\" {4}",
|
"{0} {1} {2} \"{3}\" {4}",
|
||||||
newExtent.Access,
|
newExtent.Access,
|
||||||
newExtent.Sectors,
|
newExtent.Sectors,
|
||||||
newExtent.Type,
|
newExtent.Type,
|
||||||
newExtent.Filename,
|
newExtent.Filename,
|
||||||
newExtent.Offset);
|
newExtent.Offset);
|
||||||
|
|
||||||
_extents.Add(currentSector, newExtent);
|
_extents.Add(currentSector, newExtent);
|
||||||
currentSector += newExtent.Sectors;
|
currentSector += newExtent.Sectors;
|
||||||
@@ -255,12 +255,12 @@ public sealed partial class VMware
|
|||||||
newExtent.Type = matchExtent.Groups["type"].Value;
|
newExtent.Type = matchExtent.Groups["type"].Value;
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME,
|
||||||
"{0} {1} {2} \"{3}\" {4}",
|
"{0} {1} {2} \"{3}\" {4}",
|
||||||
newExtent.Access,
|
newExtent.Access,
|
||||||
newExtent.Sectors,
|
newExtent.Sectors,
|
||||||
newExtent.Type,
|
newExtent.Type,
|
||||||
newExtent.Filename,
|
newExtent.Filename,
|
||||||
newExtent.Offset);
|
newExtent.Offset);
|
||||||
|
|
||||||
_extents.Add(currentSector, newExtent);
|
_extents.Add(currentSector, newExtent);
|
||||||
currentSector += newExtent.Sectors;
|
currentSector += newExtent.Sectors;
|
||||||
@@ -369,9 +369,9 @@ public sealed partial class VMware
|
|||||||
if(extentHdr.capacity < extent.Sectors)
|
if(extentHdr.capacity < extent.Sectors)
|
||||||
{
|
{
|
||||||
AaruLogging.Error(string.Format(Localization
|
AaruLogging.Error(string.Format(Localization
|
||||||
.Extent_contains_incorrect_number_of_sectors_0_1_were_expected,
|
.Extent_contains_incorrect_number_of_sectors_0_1_were_expected,
|
||||||
extentHdr.capacity,
|
extentHdr.capacity,
|
||||||
extent.Sectors));
|
extent.Sectors));
|
||||||
|
|
||||||
return ErrorNumber.InvalidArgument;
|
return ErrorNumber.InvalidArgument;
|
||||||
}
|
}
|
||||||
@@ -397,7 +397,7 @@ public sealed partial class VMware
|
|||||||
if(oneNoFlat && !vmEHdrSet && !cowD)
|
if(oneNoFlat && !vmEHdrSet && !cowD)
|
||||||
{
|
{
|
||||||
AaruLogging.Error(Localization
|
AaruLogging.Error(Localization
|
||||||
.There_are_sparse_extents_but_there_is_no_header_to_find_the_grain_tables_cannot_proceed);
|
.There_are_sparse_extents_but_there_is_no_header_to_find_the_grain_tables_cannot_proceed);
|
||||||
|
|
||||||
return ErrorNumber.InvalidArgument;
|
return ErrorNumber.InvalidArgument;
|
||||||
}
|
}
|
||||||
@@ -426,19 +426,13 @@ public sealed partial class VMware
|
|||||||
AaruLogging.Debug(MODULE_NAME, "vmEHdr.overhead = {0}", _vmEHdr.overhead);
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.overhead = {0}", _vmEHdr.overhead);
|
||||||
AaruLogging.Debug(MODULE_NAME, "vmEHdr.uncleanShutdown = {0}", _vmEHdr.uncleanShutdown);
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.uncleanShutdown = {0}", _vmEHdr.uncleanShutdown);
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.singleEndLineChar = 0x{0:X2}", _vmEHdr.singleEndLineChar);
|
||||||
"vmEHdr.singleEndLineChar = 0x{0:X2}",
|
|
||||||
_vmEHdr.singleEndLineChar);
|
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME, "vmEHdr.nonEndLineChar = 0x{0:X2}", _vmEHdr.nonEndLineChar);
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.nonEndLineChar = 0x{0:X2}", _vmEHdr.nonEndLineChar);
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.doubleEndLineChar1 = 0x{0:X2}", _vmEHdr.doubleEndLineChar1);
|
||||||
"vmEHdr.doubleEndLineChar1 = 0x{0:X2}",
|
|
||||||
_vmEHdr.doubleEndLineChar1);
|
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.doubleEndLineChar2 = 0x{0:X2}", _vmEHdr.doubleEndLineChar2);
|
||||||
"vmEHdr.doubleEndLineChar2 = 0x{0:X2}",
|
|
||||||
_vmEHdr.doubleEndLineChar2);
|
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME, "vmEHdr.compression = 0x{0:X4}", _vmEHdr.compression);
|
AaruLogging.Debug(MODULE_NAME, "vmEHdr.compression = 0x{0:X4}", _vmEHdr.compression);
|
||||||
|
|
||||||
@@ -471,8 +465,8 @@ public sealed partial class VMware
|
|||||||
AaruLogging.Debug(MODULE_NAME, "vmCHdr.name = {0}", StringHandlers.CToString(_vmCHdr.name));
|
AaruLogging.Debug(MODULE_NAME, "vmCHdr.name = {0}", StringHandlers.CToString(_vmCHdr.name));
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME,
|
||||||
"vmCHdr.description = {0}",
|
"vmCHdr.description = {0}",
|
||||||
StringHandlers.CToString(_vmCHdr.description));
|
StringHandlers.CToString(_vmCHdr.description));
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME, "vmCHdr.savedGeneration = {0}", _vmCHdr.savedGeneration);
|
AaruLogging.Debug(MODULE_NAME, "vmCHdr.savedGeneration = {0}", _vmCHdr.savedGeneration);
|
||||||
AaruLogging.Debug(MODULE_NAME, "vmCHdr.uncleanShutdown = {0}", _vmCHdr.uncleanShutdown);
|
AaruLogging.Debug(MODULE_NAME, "vmCHdr.uncleanShutdown = {0}", _vmCHdr.uncleanShutdown);
|
||||||
@@ -499,10 +493,10 @@ public sealed partial class VMware
|
|||||||
}
|
}
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME,
|
AaruLogging.Debug(MODULE_NAME,
|
||||||
Localization._0_sectors_in_1_grains_in_2_tables,
|
Localization._0_sectors_in_1_grains_in_2_tables,
|
||||||
_imageInfo.Sectors,
|
_imageInfo.Sectors,
|
||||||
grains,
|
grains,
|
||||||
gdEntries);
|
gdEntries);
|
||||||
|
|
||||||
Stream gdStream = _gdFilter.GetDataForkStream();
|
Stream gdStream = _gdFilter.GetDataForkStream();
|
||||||
|
|
||||||
@@ -511,7 +505,7 @@ public sealed partial class VMware
|
|||||||
AaruLogging.Debug(MODULE_NAME, Localization.Reading_grain_directory);
|
AaruLogging.Debug(MODULE_NAME, Localization.Reading_grain_directory);
|
||||||
byte[] gdBytes = new byte[gdEntries * 4];
|
byte[] gdBytes = new byte[gdEntries * 4];
|
||||||
gdStream.EnsureRead(gdBytes, 0, gdBytes.Length);
|
gdStream.EnsureRead(gdBytes, 0, gdBytes.Length);
|
||||||
Span<uint> gd = MemoryMarshal.Cast<byte, uint>(gdBytes);
|
ReadOnlySpan<uint> gd = MemoryMarshal.Cast<byte, uint>(gdBytes);
|
||||||
|
|
||||||
AaruLogging.Debug(MODULE_NAME, Localization.Reading_grain_tables);
|
AaruLogging.Debug(MODULE_NAME, Localization.Reading_grain_tables);
|
||||||
uint currentGrain = 0;
|
uint currentGrain = 0;
|
||||||
@@ -559,9 +553,7 @@ public sealed partial class VMware
|
|||||||
|
|
||||||
if(parentError != ErrorNumber.NoError)
|
if(parentError != ErrorNumber.NoError)
|
||||||
{
|
{
|
||||||
AaruLogging.Error(string.Format(Localization.Error_0_opening_parent_1,
|
AaruLogging.Error(string.Format(Localization.Error_0_opening_parent_1, parentError, _parentName));
|
||||||
parentError,
|
|
||||||
_parentName));
|
|
||||||
|
|
||||||
return parentError;
|
return parentError;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user