General cleanup and refactor.

This commit is contained in:
2022-03-07 07:36:44 +00:00
parent bc6e432565
commit 762e3eb6d2
1321 changed files with 44657 additions and 45479 deletions

View File

@@ -30,6 +30,8 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.DiscImages;
using System;
using System.Collections.Generic;
using System.IO;
@@ -43,8 +45,6 @@ using Aaru.Helpers;
using Schemas;
using Version = Aaru.CommonTypes.Interop.Version;
namespace Aaru.DiscImages;
public sealed partial class Blu
{
/// <inheritdoc />
@@ -130,7 +130,7 @@ public sealed partial class Blu
return false;
}
_writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin);
_writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin);
_writingStream.Write(data, 0, data.Length);
ErrorMessage = "";
@@ -164,7 +164,7 @@ public sealed partial class Blu
return false;
}
_writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin);
_writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin);
_writingStream.Write(data, 0, data.Length);
ErrorMessage = "";
@@ -253,7 +253,7 @@ public sealed partial class Blu
newTag ??= new byte[longSectorSize - 512];
_writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin);
_writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin);
_writingStream.Write(data, 0, 512);
_writingStream.Write(newTag, 0, newTag.Length);
@@ -304,7 +304,7 @@ public sealed partial class Blu
// Sony tag, convert to Profile
case 12 when longSectorSize == 532:
oldTag = new byte[12];
Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 12);
Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 12);
newTag = LisaTag.DecodeSonyTag(oldTag)?.ToProfile().GetBytes();
break;
@@ -312,7 +312,7 @@ public sealed partial class Blu
// Sony tag, convert to Priam
case 12:
oldTag = new byte[12];
Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 12);
Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 12);
newTag = LisaTag.DecodeSonyTag(oldTag)?.ToPriam().GetBytes();
break;
@@ -320,14 +320,14 @@ public sealed partial class Blu
// Profile tag, copy to Profile
case 20 when longSectorSize == 532:
newTag = new byte[20];
Array.Copy(data, (givenSectorSize * i) + 512, newTag, 0, 20);
Array.Copy(data, givenSectorSize * i + 512, newTag, 0, 20);
break;
// Profile tag, convert to Priam
case 20:
oldTag = new byte[20];
Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 20);
Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 20);
newTag = LisaTag.DecodeProfileTag(oldTag)?.ToPriam().GetBytes();
break;
@@ -335,7 +335,7 @@ public sealed partial class Blu
// Priam tag, convert to Profile
case 24 when longSectorSize == 532:
oldTag = new byte[24];
Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 24);
Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 24);
newTag = LisaTag.DecodePriamTag(oldTag)?.ToProfile().GetBytes();
break;
@@ -343,7 +343,7 @@ public sealed partial class Blu
// Priam tag, copy to Priam
case 24:
newTag = new byte[24];
Array.Copy(data, (givenSectorSize * i) + 512, newTag, 0, 24);
Array.Copy(data, givenSectorSize * i + 512, newTag, 0, 24);
break;
case 0:
@@ -358,8 +358,8 @@ public sealed partial class Blu
newTag ??= new byte[longSectorSize - 512];
_writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin);
_writingStream.Write(data, (int)(givenSectorSize * i), 512);
_writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin);
_writingStream.Write(data, (int)(givenSectorSize * i), 512);
_writingStream.Write(newTag, 0, newTag.Length);
}
@@ -380,7 +380,7 @@ public sealed partial class Blu
byte[] markerTag = Encoding.UTF8.GetBytes("Aaru " + Version.GetVersion());
byte[] driveName;
byte[] driveType = new byte[3];
var driveType = new byte[3];
byte[] driveBlocks = BigEndianBitConverter.GetBytes((uint)_imageInfo.Sectors);
int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532;
byte[] blockSize = BigEndianBitConverter.GetBytes((ushort)longSectorSize);