[Aaru.Images] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:34:59 +01:00
parent 6ffde343ce
commit 2cfad87955
432 changed files with 12011 additions and 8261 deletions

View File

@@ -73,7 +73,7 @@ public sealed partial class Chd
ulong offset = _hunkTable[hunkNo] & 0x00000FFFFFFFFFFF;
ulong length = _hunkTable[hunkNo] >> 44;
byte[] compHunk = new byte[length];
var compHunk = new byte[length];
_imageStream.Seek((long)offset, SeekOrigin.Begin);
_imageStream.EnsureRead(compHunk, 0, compHunk.Length);
@@ -96,8 +96,10 @@ public sealed partial class Chd
{
AaruConsole.
ErrorWriteLine(string.
Format(Localization.Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1,
read, _sectorsPerHunk * _imageInfo.SectorSize));
Format(
Localization.
Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1,
read, _sectorsPerHunk * _imageInfo.SectorSize));
return ErrorNumber.InOutError;
}
@@ -107,7 +109,7 @@ public sealed partial class Chd
break;
case 3:
byte[] entryBytes = new byte[16];
var entryBytes = new byte[16];
Array.Copy(_hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16);
MapEntryV3 entry = Marshal.ByteArrayToStructureBigEndian<MapEntryV3>(entryBytes);
@@ -120,12 +122,13 @@ public sealed partial class Chd
case EntryFlagsV3.Compressed:
switch((Compression)_hdrCompression)
{
case Compression.None: goto uncompressedV3;
case Compression.None:
goto uncompressedV3;
case Compression.Zlib:
case Compression.ZlibPlus:
if(_isHdd)
{
byte[] zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb];
var zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb];
_imageStream.Seek((long)entry.offset, SeekOrigin.Begin);
_imageStream.EnsureRead(zHunk, 0, zHunk.Length);
@@ -139,8 +142,10 @@ public sealed partial class Chd
{
AaruConsole.
ErrorWriteLine(string.
Format(Localization.Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1,
read, _bytesPerHunk));
Format(
Localization.
Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1,
read, _bytesPerHunk));
return ErrorNumber.InOutError;
}
@@ -167,7 +172,7 @@ public sealed partial class Chd
break;
case EntryFlagsV3.Uncompressed:
uncompressedV3:
uncompressedV3:
buffer = new byte[_bytesPerHunk];
_imageStream.Seek((long)entry.offset, SeekOrigin.Begin);
_imageStream.EnsureRead(buffer, 0, buffer.Length);
@@ -177,11 +182,12 @@ public sealed partial class Chd
buffer = new byte[_bytesPerHunk];
byte[] mini = BigEndianBitConverter.GetBytes(entry.offset);
for(int i = 0; i < _bytesPerHunk; i++)
for(var i = 0; i < _bytesPerHunk; i++)
buffer[i] = mini[i % 8];
break;
case EntryFlagsV3.SelfHunk: return GetHunk(entry.offset, out buffer);
case EntryFlagsV3.SelfHunk:
return GetHunk(entry.offset, out buffer);
case EntryFlagsV3.ParentHunk:
AaruConsole.ErrorWriteLine(Localization.Parent_images_are_not_supported);