General refactor and cleanup.

This commit is contained in:
2024-05-01 04:05:22 +01:00
parent 185a8c3fd5
commit e46d21bde6
922 changed files with 36437 additions and 29485 deletions

View File

@@ -47,8 +47,7 @@ public sealed partial class DriDiskCopy
{
Stream stream = imageFilter.GetDataForkStream();
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0)
return false;
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0) return false;
var buffer = new byte[Marshal.SizeOf<Footer>()];
stream.Seek(-buffer.Length, SeekOrigin.End);
@@ -74,7 +73,8 @@ public sealed partial class DriDiskCopy
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.fats_no = {0}", tmpFooter.bpb.fats_no);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.sectors = {0}", tmpFooter.bpb.sectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.media_descriptor = {0}",
AaruConsole.DebugWriteLine(MODULE_NAME,
"tmp_footer.bpb.media_descriptor = {0}",
tmpFooter.bpb.media_descriptor);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.spfat = {0}", tmpFooter.bpb.spfat);
@@ -86,7 +86,8 @@ public sealed partial class DriDiskCopy
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.unknown4 = {0}", tmpFooter.bpb.unknown4);
AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_footer.bpb.sptrack2 = {0}", tmpFooter.bpb.sptrack2);
AaruConsole.DebugWriteLine(MODULE_NAME, "ArrayHelpers.ArrayIsNullOrEmpty(tmp_footer.bpb.unknown5) = {0}",
AaruConsole.DebugWriteLine(MODULE_NAME,
"ArrayHelpers.ArrayIsNullOrEmpty(tmp_footer.bpb.unknown5) = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(tmpFooter.bpb.unknown5));
var regexSignature = new Regex(REGEX_DRI);
@@ -94,11 +95,9 @@ public sealed partial class DriDiskCopy
AaruConsole.DebugWriteLine(MODULE_NAME, "MatchSignature.Success? = {0}", matchSignature.Success);
if(!matchSignature.Success)
return false;
if(!matchSignature.Success) return false;
if(tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors)
return false;
if(tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors) return false;
return tmpFooter.bpb.sectors * tmpFooter.bpb.bps + Marshal.SizeOf<Footer>() == stream.Length;
}

View File

@@ -44,6 +44,7 @@ public sealed partial class DriDiskCopy
#region IWritableImage Members
/// <inheritdoc />
// ReSharper disable once ConvertToAutoProperty
public ImageInfo Info => _imageInfo;

View File

@@ -49,8 +49,7 @@ public sealed partial class DriDiskCopy
{
Stream stream = imageFilter.GetDataForkStream();
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0)
return ErrorNumber.InvalidArgument;
if((stream.Length - Marshal.SizeOf<Footer>()) % 512 != 0) return ErrorNumber.InvalidArgument;
var buffer = new byte[Marshal.SizeOf<Footer>()];
stream.Seek(-buffer.Length, SeekOrigin.End);
@@ -63,8 +62,7 @@ public sealed partial class DriDiskCopy
var regexSignature = new Regex(REGEX_DRI);
Match matchSignature = regexSignature.Match(sig);
if(!matchSignature.Success)
return ErrorNumber.InvalidArgument;
if(!matchSignature.Success) return ErrorNumber.InvalidArgument;
if(_footer.bpb.sptrack * _footer.bpb.cylinders * _footer.bpb.heads != _footer.bpb.sectors)
return ErrorNumber.InvalidArgument;
@@ -85,7 +83,9 @@ public sealed partial class DriDiskCopy
_imageInfo.CreationTime = imageFilter.CreationTime;
_imageInfo.LastModificationTime = imageFilter.LastWriteTime;
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Image_application_0_version_1, _imageInfo.Application,
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Image_application_0_version_1,
_imageInfo.Application,
_imageInfo.ApplicationVersion);
// Correct some incorrect data in images of NEC 2HD disks
@@ -132,11 +132,9 @@ public sealed partial class DriDiskCopy
{
buffer = null;
if(sectorAddress > _imageInfo.Sectors - 1)
return ErrorNumber.OutOfRange;
if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors)
return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange;
buffer = new byte[length * _imageInfo.SectorSize];