Update ReadSector and ReadSectors methods to include sector status output

This commit is contained in:
2025-10-22 14:28:58 +01:00
parent 1003088cc3
commit 0ac2a48fb6
238 changed files with 5881 additions and 5196 deletions

View File

@@ -109,15 +109,15 @@ public sealed class Entropy
currentTrack.Sequence,
inputTracks.Max(t => t.Sequence));
ulong[] entTable = new ulong[256];
var entTable = new ulong[256];
ulong trackSize = 0;
List<string> uniqueSectorsPerTrack = [];
trackEntropy.Sectors = currentTrack.EndSector - currentTrack.StartSector + 1;
AaruLogging.Verbose(Localization.Core.Track_0_has_1_sectors,
currentTrack.Sequence,
trackEntropy.Sectors);
currentTrack.Sequence,
trackEntropy.Sectors);
InitProgress2Event?.Invoke();
@@ -129,14 +129,14 @@ public sealed class Entropy
(long)(i + 1),
(long)currentTrack.EndSector);
ErrorNumber errno = opticalMediaImage.ReadSector(i, currentTrack.Sequence, out byte[] sector);
ErrorNumber errno =
opticalMediaImage.ReadSector(i, currentTrack.Sequence, out byte[] sector, out _);
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core
.Error_0_while_reading_sector_1_continuing,
errno,
i));
AaruLogging.Error(string.Format(Localization.Core.Error_0_while_reading_sector_1_continuing,
errno,
i));
continue;
}
@@ -175,8 +175,7 @@ public sealed class Entropy
}
else
{
AaruLogging.Error(Localization.Core
.Unable_to_get_separate_tracks_not_calculating_their_entropy);
AaruLogging.Error(Localization.Core.Unable_to_get_separate_tracks_not_calculating_their_entropy);
}
}
@@ -195,7 +194,7 @@ public sealed class Entropy
if(_inputFormat is not IMediaImage mediaImage) return entropy;
ulong[] entTable = new ulong[256];
var entTable = new ulong[256];
ulong diskSize = 0;
List<string> uniqueSectors = [];
@@ -209,13 +208,11 @@ public sealed class Entropy
(long)(i + 1),
(long)entropy.Sectors);
ErrorNumber errno = mediaImage.ReadSector(i, out byte[] sector);
ErrorNumber errno = mediaImage.ReadSector(i, out byte[] sector, out _);
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_while_reading_sector_1_continuing,
errno,
i));
AaruLogging.Error(string.Format(Localization.Core.Error_0_while_reading_sector_1_continuing, errno, i));
continue;
}
@@ -254,8 +251,8 @@ public sealed class Entropy
if(_inputFormat is not IByteAddressableImage byteAddressableImage) return entropy;
ulong[] entTable = new ulong[256];
byte[] data = new byte[byteAddressableImage.Info.Sectors];
var entTable = new ulong[256];
var data = new byte[byteAddressableImage.Info.Sectors];
entropy.Sectors = _inputFormat.Info.Sectors;
AaruLogging.WriteLine(Localization.Core._0_bytes, entropy.Sectors);
@@ -265,15 +262,14 @@ public sealed class Entropy
if(errno != ErrorNumber.NoError)
{
AaruLogging.Error(string.Format(Localization.Core.Error_0_while_reading_data__not_continuing,
errno));
AaruLogging.Error(string.Format(Localization.Core.Error_0_while_reading_data__not_continuing, errno));
return entropy;
}
if(bytesRead != data.Length)
{
byte[] tmp = new byte[bytesRead];
var tmp = new byte[bytesRead];
Array.Copy(data, 0, tmp, 0, bytesRead);
data = tmp;
}

View File

@@ -401,7 +401,7 @@ public sealed partial class Sidecar
if(sectors - doneSectors >= sectorsToRead)
{
errno = image.ReadSectors(doneSectors, sectorsToRead, out sector);
errno = image.ReadSectors(doneSectors, sectorsToRead, out sector, out _);
if(errno != ErrorNumber.NoError)
{
@@ -416,7 +416,7 @@ public sealed partial class Sidecar
}
else
{
errno = image.ReadSectors(doneSectors, (uint)(sectors - doneSectors), out sector);
errno = image.ReadSectors(doneSectors, (uint)(sectors - doneSectors), out sector, out _);
if(errno != ErrorNumber.NoError)
{
@@ -502,7 +502,8 @@ public sealed partial class Sidecar
{
errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors,
sectorsToRead,
out sector);
out sector,
out _);
if(errno != ErrorNumber.NoError)
{
@@ -522,7 +523,8 @@ public sealed partial class Sidecar
{
errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors,
(uint)(sectors - doneSectors),
out sector);
out sector,
out _);
if(errno != ErrorNumber.NoError)
{
@@ -602,7 +604,10 @@ public sealed partial class Sidecar
if(sectors - doneSectors >= sectorsToRead)
{
errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, sectorsToRead, out sector);
errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors,
sectorsToRead,
out sector,
out _);
if(errno != ErrorNumber.NoError)
{
@@ -625,7 +630,8 @@ public sealed partial class Sidecar
{
errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors,
(uint)(sectors - doneSectors),
out sector);
out sector,
out _);
if(errno != ErrorNumber.NoError)
{
@@ -1023,7 +1029,7 @@ public sealed partial class Sidecar
if(scpImage.ScpTracks.TryGetValue(t, out SuperCardPro.TrackHeader scpTrack))
{
byte[] trackContents =
var trackContents =
new byte[scpTrack.Entries.Last().dataOffset +
scpTrack.Entries.Last().trackLength -
scpImage.Header.offsets[t] +
@@ -1065,7 +1071,7 @@ public sealed partial class Sidecar
string basename = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath));
bool kfDir = false;
var kfDir = false;
if(_aborted) return;
@@ -1138,7 +1144,7 @@ public sealed partial class Sidecar
}
Stream kfStream = kvp.Value.GetDataForkStream();
byte[] trackContents = new byte[kfStream.Length];
var trackContents = new byte[kfStream.Length];
kfStream.Position = 0;
kfStream.EnsureRead(trackContents, 0, trackContents.Length);
kfBlockTrackType.Size = (ulong)trackContents.Length;
@@ -1229,7 +1235,7 @@ public sealed partial class Sidecar
dfiImage.TrackLengths.TryGetValue(t, out long length))
{
dfiBlockTrackType.Image.Offset = (ulong)offset;
byte[] trackContents = new byte[length];
var trackContents = new byte[length];
dfiStream.Position = offset;
dfiStream.EnsureRead(trackContents, 0, trackContents.Length);
dfiBlockTrackType.Size = (ulong)trackContents.Length;

View File

@@ -358,7 +358,11 @@ public sealed partial class Sidecar
if(sectors - doneSectors >= sectorsToRead)
{
errno = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.Number, out sector);
errno = image.ReadSectorsLong(doneSectors,
sectorsToRead,
xmlTrk.Sequence.Number,
out sector,
out _);
UpdateProgress2(Localization.Core.Hashing_sector_0_of_1,
(long)doneSectors,
@@ -379,7 +383,8 @@ public sealed partial class Sidecar
errno = image.ReadSectorsLong(doneSectors,
(uint)(sectors - doneSectors),
xmlTrk.Sequence.Number,
out sector);
out sector,
out _);
UpdateProgress2(Localization.Core.Hashing_sector_0_of_1,
(long)doneSectors,