diff --git a/Aaru.CommonTypes/Interfaces/IMediaImage.cs b/Aaru.CommonTypes/Interfaces/IMediaImage.cs
index 71eb1ce19..beaf8b40f 100644
--- a/Aaru.CommonTypes/Interfaces/IMediaImage.cs
+++ b/Aaru.CommonTypes/Interfaces/IMediaImage.cs
@@ -55,27 +55,31 @@ public interface IMediaImage : IBaseImage
/// The sector's user data.
/// Sector address (LBA).
///
- ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer);
+ ///
+ ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus);
/// Reads a complete sector (user data + all tags).
/// The complete sector. Format depends on disk type.
/// Sector address (LBA).
///
- ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer);
+ ///
+ ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus);
/// Reads user data from several sectors.
/// The sectors user data.
/// Starting sector address (LBA).
/// How many sectors to read.
///
- ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer);
+ ///
+ ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus);
/// Reads several complete sector (user data + all tags).
/// The complete sectors. Format depends on disk type.
/// Starting sector address (LBA).
/// How many sectors to read.
///
- ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer);
+ ///
+ ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus);
/// Reads tag from several sectors.
/// The sectors tag.
diff --git a/Aaru.CommonTypes/Interfaces/IOpticalMediaImage.cs b/Aaru.CommonTypes/Interfaces/IOpticalMediaImage.cs
index bd105fb41..acbf17e60 100644
--- a/Aaru.CommonTypes/Interfaces/IOpticalMediaImage.cs
+++ b/Aaru.CommonTypes/Interfaces/IOpticalMediaImage.cs
@@ -63,7 +63,8 @@ public interface IOpticalMediaImage : IMediaImage, IPartitionableMediaImage, IVe
/// Sector address (relative LBA).
/// Track.
///
- ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer);
+ ///
+ ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus);
/// Reads a sector's tag, relative to track.
/// The sector's tag.
@@ -79,7 +80,9 @@ public interface IOpticalMediaImage : IMediaImage, IPartitionableMediaImage, IVe
/// How many sectors to read.
/// Track.
///
- ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer);
+ ///
+ ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer,
+ out SectorStatus[] sectorStatus);
/// Reads tag from several sectors, relative to track.
/// The sectors tag.
@@ -95,7 +98,8 @@ public interface IOpticalMediaImage : IMediaImage, IPartitionableMediaImage, IVe
/// Sector address (relative LBA).
/// Track.
///
- ErrorNumber ReadSectorLong(ulong sectorAddress, uint track, out byte[] buffer);
+ ///
+ ErrorNumber ReadSectorLong(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus);
/// Reads several complete sector (user data + all tags), relative to track.
/// The complete sectors. Format depends on disk type.
@@ -103,7 +107,9 @@ public interface IOpticalMediaImage : IMediaImage, IPartitionableMediaImage, IVe
/// How many sectors to read.
/// Track.
///
- ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer);
+ ///
+ ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer,
+ out SectorStatus[] sectorStatus);
/// Gets the disc track extents for a specified session.
/// The track extents for that session.
diff --git a/Aaru.Core/Entropy.cs b/Aaru.Core/Entropy.cs
index b7bcc1409..a6a7fff09 100644
--- a/Aaru.Core/Entropy.cs
+++ b/Aaru.Core/Entropy.cs
@@ -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 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 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;
}
diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs
index 69afb11df..e48672f0c 100644
--- a/Aaru.Core/Sidecar/BlockMedia.cs
+++ b/Aaru.Core/Sidecar/BlockMedia.cs
@@ -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;
diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs
index d00e3d03b..bbe32de8a 100644
--- a/Aaru.Core/Sidecar/OpticalDisc.cs
+++ b/Aaru.Core/Sidecar/OpticalDisc.cs
@@ -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,
diff --git a/Aaru.Decryption/DVD/CSS.cs b/Aaru.Decryption/DVD/CSS.cs
index 3bb70ded6..4a6e9e57c 100644
--- a/Aaru.Decryption/DVD/CSS.cs
+++ b/Aaru.Decryption/DVD/CSS.cs
@@ -432,36 +432,36 @@ public class CSS
/// The encrypted key.
public static void EncryptKey(DvdCssKeyType keyType, uint variant, byte[] challenge, out byte[] key)
{
- byte[] bits = new byte[30];
- byte[] scratch = new byte[10];
- byte index = sizeof(byte) * 30;
- byte[] temp1 = new byte[5];
- byte[] temp2 = new byte[5];
- byte carry = 0;
+ var bits = new byte[30];
+ var scratch = new byte[10];
+ byte index = sizeof(byte) * 30;
+ var temp1 = new byte[5];
+ var temp2 = new byte[5];
+ byte carry = 0;
key = new byte[5];
- for(int i = 9; i >= 0; --i) scratch[i] = challenge[_permutationChallenge[(uint)keyType, i]];
+ for(var i = 9; i >= 0; --i) scratch[i] = challenge[_permutationChallenge[(uint)keyType, i]];
- byte cssVariant = (byte)(keyType == 0 ? variant : _permutationVariant[(uint)keyType - 1, variant]);
+ var cssVariant = (byte)(keyType == 0 ? variant : _permutationVariant[(uint)keyType - 1, variant]);
- for(int i = 5; --i >= 0;) temp1[i] = (byte)(scratch[5 + i] ^ _secret[i] ^ _encryptTable2[i]);
+ for(var i = 5; --i >= 0;) temp1[i] = (byte)(scratch[5 + i] ^ _secret[i] ^ _encryptTable2[i]);
- uint lfsr0 = (uint)(temp1[0] << 17 | temp1[1] << 9 | (temp1[2] & ~7) << 1 | 8 | temp1[2] & 7);
- uint lfsr1 = (uint)(temp1[3] << 9 | 0x100 | temp1[4]);
+ var lfsr0 = (uint)(temp1[0] << 17 | temp1[1] << 9 | (temp1[2] & ~7) << 1 | 8 | temp1[2] & 7);
+ var lfsr1 = (uint)(temp1[3] << 9 | 0x100 | temp1[4]);
do
{
byte val = 0;
- for(int bit = 0; bit < 8; ++bit)
+ for(var bit = 0; bit < 8; ++bit)
{
- byte oLfsr0 = (byte)((lfsr0 >> 24 ^ lfsr0 >> 21 ^ lfsr0 >> 20 ^ lfsr0 >> 12) & 1);
+ var oLfsr0 = (byte)((lfsr0 >> 24 ^ lfsr0 >> 21 ^ lfsr0 >> 20 ^ lfsr0 >> 12) & 1);
lfsr0 = lfsr0 << 1 | oLfsr0;
- byte oLfsr1 = (byte)((lfsr1 >> 16 ^ lfsr1 >> 2) & 1);
+ var oLfsr1 = (byte)((lfsr1 >> 16 ^ lfsr1 >> 2) & 1);
lfsr1 = lfsr1 << 1 | oLfsr1;
- byte combined = (byte)(Convert.ToByte(oLfsr1 == 0) + carry + Convert.ToByte(oLfsr0 == 0));
+ var combined = (byte)(Convert.ToByte(oLfsr1 == 0) + carry + Convert.ToByte(oLfsr0 == 0));
carry = (byte)(combined >> 1 & 1);
val |= (byte)((combined & 1) << bit);
}
@@ -469,10 +469,10 @@ public class CSS
bits[--index] = val;
} while(index > 0);
- byte cse = (byte)(_variants[cssVariant] ^ _encryptTable2[cssVariant]);
- int term = 0;
+ var cse = (byte)(_variants[cssVariant] ^ _encryptTable2[cssVariant]);
+ var term = 0;
- for(int i = 5; --i >= 0; term = scratch[i])
+ for(var i = 5; --i >= 0; term = scratch[i])
{
index = (byte)(bits[25 + i] ^ scratch[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -483,7 +483,7 @@ public class CSS
temp1[4] ^= temp1[0];
term = 0;
- for(int i = 5; --i >= 0; term = temp1[i])
+ for(var i = 5; --i >= 0; term = temp1[i])
{
index = (byte)(bits[20 + i] ^ temp1[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -494,7 +494,7 @@ public class CSS
temp2[4] ^= temp2[0];
term = 0;
- for(int i = 5; --i >= 0; term = temp2[i])
+ for(var i = 5; --i >= 0; term = temp2[i])
{
index = (byte)(bits[15 + i] ^ temp2[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -506,7 +506,7 @@ public class CSS
temp1[4] ^= temp1[0];
term = 0;
- for(int i = 5; --i >= 0; term = temp1[i])
+ for(var i = 5; --i >= 0; term = temp1[i])
{
index = (byte)(bits[10 + i] ^ temp1[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -518,7 +518,7 @@ public class CSS
temp2[4] ^= temp2[0];
term = 0;
- for(int i = 5; --i >= 0; term = temp2[i])
+ for(var i = 5; --i >= 0; term = temp2[i])
{
index = (byte)(bits[5 + i] ^ temp2[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -529,7 +529,7 @@ public class CSS
temp1[4] ^= temp1[0];
term = 0;
- for(int i = 5; --i >= 0; term = temp1[i])
+ for(var i = 5; --i >= 0; term = temp1[i])
{
index = (byte)(bits[i] ^ temp1[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -546,12 +546,12 @@ public class CSS
static void DecryptKey(byte invert, byte[] cryptoKey, byte[] encryptedKey, out byte[] decryptedKey)
{
decryptedKey = new byte[5];
- byte[] k = new byte[5];
+ var k = new byte[5];
- uint lfsr1Lo = (uint)(cryptoKey[0] | 0x100);
+ var lfsr1Lo = (uint)(cryptoKey[0] | 0x100);
uint lfsr1Hi = cryptoKey[1];
- uint lfsr0 = (uint)((cryptoKey[4] << 17 | cryptoKey[3] << 9 | cryptoKey[2] << 1) + 8 - (cryptoKey[2] & 7));
+ var lfsr0 = (uint)((cryptoKey[4] << 17 | cryptoKey[3] << 9 | cryptoKey[2] << 1) + 8 - (cryptoKey[2] & 7));
lfsr0 = (uint)(_cssTable4[lfsr0 & 0xff] << 24 |
_cssTable4[lfsr0 >> 8 & 0xff] << 16 |
@@ -562,11 +562,11 @@ public class CSS
for(uint i = 0; i < 5; i++)
{
- byte oLfsr1 = (byte)(_cssTable2[lfsr1Hi] ^ _cssTable3[lfsr1Lo]);
+ var oLfsr1 = (byte)(_cssTable2[lfsr1Hi] ^ _cssTable3[lfsr1Lo]);
lfsr1Hi = lfsr1Lo >> 1;
lfsr1Lo = (lfsr1Lo & 1) << 8 ^ oLfsr1;
oLfsr1 = _cssTable4[oLfsr1];
- byte oLfsr0 = (byte)((((lfsr0 >> 8 ^ lfsr0) >> 1 ^ lfsr0) >> 3 ^ lfsr0) >> 7);
+ var oLfsr0 = (byte)((((lfsr0 >> 8 ^ lfsr0) >> 1 ^ lfsr0) >> 3 ^ lfsr0) >> 7);
lfsr0 = lfsr0 >> 8 | (uint)oLfsr0 << 24;
combined += (uint)((oLfsr0 ^ invert) + oLfsr1);
k[i] = (byte)(combined & 0xff);
@@ -632,7 +632,7 @@ public class CSS
if(cmiData != null && cmiData.All(static cmi => (cmi & 0x80) >> 7 == 0) || keyData.All(static k => k == 0))
return sectorData;
- byte[] decryptedBuffer = new byte[sectorData.Length];
+ var decryptedBuffer = new byte[sectorData.Length];
for(uint i = 0; i < blocks; i++)
{
@@ -670,7 +670,7 @@ public class CSS
if(cmiData != null && cmiData.All(static cmi => (cmi & 0x80) >> 7 == 0) || keyData.All(static k => k == 0))
return sectorData;
- byte[] decryptedBuffer = new byte[sectorData.Length];
+ var decryptedBuffer = new byte[sectorData.Length];
for(uint i = 0; i < blocks; i++)
{
@@ -825,7 +825,7 @@ public class CSS
// If we found an adequate pattern.
if(bestPattern <= 0 || bestPatternLength <= 3 || bestPatternLength / bestPattern < 2) return false;
- int offset = (int)(0x80 - bestPatternLength / bestPattern * bestPattern);
+ var offset = (int)(0x80 - bestPatternLength / bestPattern * bestPattern);
int result = RecoverTitleKey(0,
sector.Skip(0x80).Take(sector.Length - 0x80).ToArray(),
@@ -849,10 +849,10 @@ public class CSS
static int RecoverTitleKey(uint start, byte[] encryptedBytes, byte[] decryptedBytes, byte[] sectorSeed,
out byte[] key)
{
- byte[] buffer = new byte[10];
- long iTry;
- uint i;
- int exit = -1;
+ var buffer = new byte[10];
+ long iTry;
+ uint i;
+ int exit = -1;
key = new byte[5];
for(i = 0; i < 10; i++) buffer[i] = (byte)(_cssTable1[encryptedBytes[i]] ^ decryptedBytes[i]);
@@ -960,11 +960,11 @@ public class CSS
/// The title key.
static byte[] FindTitleKey(IOpticalMediaImage input, ulong startSector, ulong sectorsToSearch = 20000)
{
- byte[] titleKey = new byte[5];
+ var titleKey = new byte[5];
for(ulong i = 0; i < sectorsToSearch; i++)
{
- input.ReadSector(startSector + i, out byte[] sector);
+ input.ReadSector(startSector + i, out byte[] sector, out _);
if(!IsEncrypted(null, null, sector)) continue;
@@ -985,7 +985,7 @@ public class CSS
public static byte[] GenerateTitleKeys(IOpticalMediaImage input, List partitions, ulong trackSectors,
IReadOnlyFilesystem fs)
{
- byte[] keys = new byte[trackSectors * 5];
+ var keys = new byte[trackSectors * 5];
foreach(Partition partition in partitions)
{
diff --git a/Aaru.Filesystems/AODOS/Info.cs b/Aaru.Filesystems/AODOS/Info.cs
index 36ffc92f5..778efd3be 100644
--- a/Aaru.Filesystems/AODOS/Info.cs
+++ b/Aaru.Filesystems/AODOS/Info.cs
@@ -60,7 +60,7 @@ public sealed partial class AODOS
// Does AO-DOS support any other kind of disk?
if(imagePlugin.Info.Sectors != 800 && imagePlugin.Info.Sectors != 1600) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -75,7 +75,7 @@ public sealed partial class AODOS
{
information = "";
encoding = Encoding.GetEncoding("koi8-r");
- ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _);
metadata = new FileSystem();
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/APFS/Info.cs b/Aaru.Filesystems/APFS/Info.cs
index 40ad0731f..0d63a6afd 100644
--- a/Aaru.Filesystems/APFS/Info.cs
+++ b/Aaru.Filesystems/APFS/Info.cs
@@ -50,7 +50,7 @@ public sealed partial class APFS
{
if(partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -80,7 +80,7 @@ public sealed partial class APFS
if(partition.Start >= partition.End) return;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/Acorn/Info.cs b/Aaru.Filesystems/Acorn/Info.cs
index 988a601e0..99c205462 100644
--- a/Aaru.Filesystems/Acorn/Info.cs
+++ b/Aaru.Filesystems/Acorn/Info.cs
@@ -60,14 +60,14 @@ public sealed partial class AcornADFS
// ADFS-S, ADFS-M, ADFS-L, ADFS-D without partitions
if(partition.Start == 0)
{
- errno = imagePlugin.ReadSector(0, out sector);
+ errno = imagePlugin.ReadSector(0, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
byte oldChk0 = AcornMapChecksum(sector, 255);
OldMapSector0 oldMap0 = Marshal.ByteArrayToStructureLittleEndian(sector);
- errno = imagePlugin.ReadSector(1, out sector);
+ errno = imagePlugin.ReadSector(1, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -80,11 +80,11 @@ public sealed partial class AcornADFS
// According to documentation map1 MUST start on sector 1. On ADFS-D it starts at 0x100, not on sector 1 (0x400)
if(oldMap0.checksum == oldChk0 && oldMap1.checksum != oldChk1 && sector.Length >= 512)
{
- errno = imagePlugin.ReadSector(0, out sector);
+ errno = imagePlugin.ReadSector(0, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
- byte[] tmp = new byte[256];
+ var tmp = new byte[256];
Array.Copy(sector, 256, tmp, 0, 256);
oldChk1 = AcornMapChecksum(tmp, 255);
oldMap1 = Marshal.ByteArrayToStructureLittleEndian(tmp);
@@ -103,13 +103,13 @@ public sealed partial class AcornADFS
if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector);
+ errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
if(sector.Length > OLD_DIRECTORY_SIZE)
{
- byte[] tmp = new byte[OLD_DIRECTORY_SIZE];
+ var tmp = new byte[OLD_DIRECTORY_SIZE];
Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53);
Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53);
sector = tmp;
@@ -122,9 +122,7 @@ public sealed partial class AcornADFS
AaruLogging.Debug(MODULE_NAME, "oldRoot.tail.magic at 0x200 = {0}", oldRoot.tail.magic);
- AaruLogging.Debug(MODULE_NAME,
- "oldRoot.tail.checkByte at 0x200 = {0}",
- oldRoot.tail.checkByte);
+ AaruLogging.Debug(MODULE_NAME, "oldRoot.tail.checkByte at 0x200 = {0}", oldRoot.tail.checkByte);
AaruLogging.Debug(MODULE_NAME, "dirChk at 0x200 = {0}", dirChk);
@@ -138,13 +136,13 @@ public sealed partial class AcornADFS
if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector);
+ errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
if(sector.Length > OLD_DIRECTORY_SIZE)
{
- byte[] tmp = new byte[OLD_DIRECTORY_SIZE];
+ var tmp = new byte[OLD_DIRECTORY_SIZE];
Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53);
Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53);
sector = tmp;
@@ -157,9 +155,7 @@ public sealed partial class AcornADFS
AaruLogging.Debug(MODULE_NAME, "oldRoot.tail.magic at 0x400 = {0}", oldRoot.tail.magic);
- AaruLogging.Debug(MODULE_NAME,
- "oldRoot.tail.checkByte at 0x400 = {0}",
- oldRoot.tail.checkByte);
+ AaruLogging.Debug(MODULE_NAME, "oldRoot.tail.checkByte at 0x400 = {0}", oldRoot.tail.checkByte);
AaruLogging.Debug(MODULE_NAME, "dirChk at 0x400 = {0}", dirChk);
@@ -172,7 +168,7 @@ public sealed partial class AcornADFS
// Partitioning or not, new formats follow:
DiscRecord drSb;
- errno = imagePlugin.ReadSector(partition.Start, out sector);
+ errno = imagePlugin.ReadSector(partition.Start, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -187,15 +183,15 @@ public sealed partial class AcornADFS
if(sbSector + partition.Start + sectorsToRead >= partition.End) return false;
- errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector);
+ errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector, out _);
if(errno != ErrorNumber.NoError) return false;
- int bootChk = 0;
+ var bootChk = 0;
if(bootSector.Length < 512) return false;
- for(int i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i];
+ for(var i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i];
AaruLogging.Debug(MODULE_NAME, "bootChk = {0}", bootChk);
AaruLogging.Debug(MODULE_NAME, "bBlock.checksum = {0}", bootSector[0x1FF]);
@@ -219,8 +215,8 @@ public sealed partial class AcornADFS
AaruLogging.Debug(MODULE_NAME, "drSb.disc_size = {0}", drSb.disc_size);
AaruLogging.Debug(MODULE_NAME,
- "IsNullOrEmpty(drSb.reserved) = {0}",
- ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved));
+ "IsNullOrEmpty(drSb.reserved) = {0}",
+ ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved));
if(drSb.log2secsize is < 8 or > 10) return false;
@@ -258,14 +254,14 @@ public sealed partial class AcornADFS
// ADFS-S, ADFS-M, ADFS-L, ADFS-D without partitions
if(partition.Start == 0)
{
- errno = imagePlugin.ReadSector(0, out sector);
+ errno = imagePlugin.ReadSector(0, out sector, out _);
if(errno != ErrorNumber.NoError) return;
byte oldChk0 = AcornMapChecksum(sector, 255);
OldMapSector0 oldMap0 = Marshal.ByteArrayToStructureLittleEndian(sector);
- errno = imagePlugin.ReadSector(1, out sector);
+ errno = imagePlugin.ReadSector(1, out sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -275,11 +271,11 @@ public sealed partial class AcornADFS
// According to documentation map1 MUST start on sector 1. On ADFS-D it starts at 0x100, not on sector 1 (0x400)
if(oldMap0.checksum == oldChk0 && oldMap1.checksum != oldChk1 && sector.Length >= 512)
{
- errno = imagePlugin.ReadSector(0, out sector);
+ errno = imagePlugin.ReadSector(0, out sector, out _);
if(errno != ErrorNumber.NoError) return;
- byte[] tmp = new byte[256];
+ var tmp = new byte[256];
Array.Copy(sector, 256, tmp, 0, 256);
oldChk1 = AcornMapChecksum(tmp, 255);
oldMap1 = Marshal.ByteArrayToStructureLittleEndian(tmp);
@@ -291,9 +287,9 @@ public sealed partial class AcornADFS
oldMap1.checksum != 0)
{
bytes = (ulong)((oldMap0.size[2] << 16) + (oldMap0.size[1] << 8) + oldMap0.size[0]) * 256;
- byte[] namebytes = new byte[10];
+ var namebytes = new byte[10];
- for(int i = 0; i < 5; i++)
+ for(var i = 0; i < 5; i++)
{
namebytes[i * 2] = oldMap0.name[i];
namebytes[i * 2 + 1] = oldMap1.name[i];
@@ -314,13 +310,13 @@ public sealed partial class AcornADFS
if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector);
+ errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _);
if(errno != ErrorNumber.NoError) return;
if(sector.Length > OLD_DIRECTORY_SIZE)
{
- byte[] tmp = new byte[OLD_DIRECTORY_SIZE];
+ var tmp = new byte[OLD_DIRECTORY_SIZE];
Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53);
Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53);
sector = tmp;
@@ -338,13 +334,13 @@ public sealed partial class AcornADFS
if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector);
+ errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _);
if(errno != ErrorNumber.NoError) return;
if(sector.Length > OLD_DIRECTORY_SIZE)
{
- byte[] tmp = new byte[OLD_DIRECTORY_SIZE];
+ var tmp = new byte[OLD_DIRECTORY_SIZE];
Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53);
Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53);
@@ -358,13 +354,13 @@ public sealed partial class AcornADFS
namebytes = oldRoot.tail.name;
else
{
- errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector);
+ errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _);
if(errno != ErrorNumber.NoError) return;
if(sector.Length > NEW_DIRECTORY_SIZE)
{
- byte[] tmp = new byte[NEW_DIRECTORY_SIZE];
+ var tmp = new byte[NEW_DIRECTORY_SIZE];
Array.Copy(sector, 0, tmp, 0, NEW_DIRECTORY_SIZE - 41);
Array.Copy(sector, sector.Length - 42, tmp, NEW_DIRECTORY_SIZE - 42, 41);
@@ -406,7 +402,7 @@ public sealed partial class AcornADFS
// Partitioning or not, new formats follow:
DiscRecord drSb;
- errno = imagePlugin.ReadSector(partition.Start, out sector);
+ errno = imagePlugin.ReadSector(partition.Start, out sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -419,13 +415,13 @@ public sealed partial class AcornADFS
if(BOOT_BLOCK_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector);
+ errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector, out _);
if(errno != ErrorNumber.NoError) return;
- int bootChk = 0;
+ var bootChk = 0;
- for(int i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i];
+ for(var i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i];
AaruLogging.Debug(MODULE_NAME, "bootChk = {0}", bootChk);
AaruLogging.Debug(MODULE_NAME, "bBlock.checksum = {0}", bootSector[0x1FF]);
@@ -458,9 +454,7 @@ public sealed partial class AcornADFS
AaruLogging.Debug(MODULE_NAME, "drSb.disc_size = {0}", drSb.disc_size);
AaruLogging.Debug(MODULE_NAME, "drSb.disc_id = {0}", drSb.disc_id);
- AaruLogging.Debug(MODULE_NAME,
- "drSb.disc_name = {0}",
- StringHandlers.CToString(drSb.disc_name, encoding));
+ AaruLogging.Debug(MODULE_NAME, "drSb.disc_name = {0}", StringHandlers.CToString(drSb.disc_name, encoding));
AaruLogging.Debug(MODULE_NAME, "drSb.disc_type = {0}", drSb.disc_type);
AaruLogging.Debug(MODULE_NAME, "drSb.disc_size_high = {0}", drSb.disc_size_high);
diff --git a/Aaru.Filesystems/AmigaDOS/Info.cs b/Aaru.Filesystems/AmigaDOS/Info.cs
index d7cb661fb..85f4e36ba 100644
--- a/Aaru.Filesystems/AmigaDOS/Info.cs
+++ b/Aaru.Filesystems/AmigaDOS/Info.cs
@@ -56,7 +56,7 @@ public sealed partial class AmigaDOSPlugin
// However while you can set a block size different from the sector size on formatting, the bootblock block
// size for floppies is the sector size, and for RDB is usually is the hard disk sector size,
// so this is not entirely wrong...
- ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -69,7 +69,7 @@ public sealed partial class AmigaDOSPlugin
(bblk.diskType & FFS_MASK) != FFS_MASK &&
(bblk.diskType & MUFS_MASK) != MUFS_MASK)
{
- errno = imagePlugin.ReadSectors(1 + partition.Start, 2, out sector);
+ errno = imagePlugin.ReadSectors(1 + partition.Start, 2, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -110,7 +110,7 @@ public sealed partial class AmigaDOSPlugin
{
AaruLogging.Debug(MODULE_NAME, Localization.Searching_for_Rootblock_in_sector_0, rootPtr);
- errno = imagePlugin.ReadSector(rootPtr, out sector);
+ errno = imagePlugin.ReadSector(rootPtr, out sector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -133,7 +133,7 @@ public sealed partial class AmigaDOSPlugin
if(rootPtr + sectorsPerBlock >= partition.End) continue;
- errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out sector);
+ errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out sector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -162,7 +162,7 @@ public sealed partial class AmigaDOSPlugin
var sbInformation = new StringBuilder();
metadata = new FileSystem();
information = null;
- ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] bootBlockSectors);
+ ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] bootBlockSectors, out _);
if(errno != ErrorNumber.NoError) return;
@@ -200,7 +200,7 @@ public sealed partial class AmigaDOSPlugin
{
AaruLogging.Debug(MODULE_NAME, Localization.Searching_for_Rootblock_in_sector_0, rootPtr);
- errno = imagePlugin.ReadSector(rootPtr, out rootBlockSector);
+ errno = imagePlugin.ReadSector(rootPtr, out rootBlockSector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -223,7 +223,7 @@ public sealed partial class AmigaDOSPlugin
if(rootPtr + sectorsPerBlock >= partition.End) continue;
- errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector);
+ errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -240,7 +240,7 @@ public sealed partial class AmigaDOSPlugin
if(rootBlk.sec_type != SUBTYPE_ROOT || rootBlk.checksum != rsum) continue;
- errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector);
+ errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector, out _);
if(errno != ErrorNumber.NoError) continue;
diff --git a/Aaru.Filesystems/AppleDOS/Dir.cs b/Aaru.Filesystems/AppleDOS/Dir.cs
index 1398aa9d8..a2dcd3459 100644
--- a/Aaru.Filesystems/AppleDOS/Dir.cs
+++ b/Aaru.Filesystems/AppleDOS/Dir.cs
@@ -42,6 +42,60 @@ namespace Aaru.Filesystems;
public sealed partial class AppleDOS
{
+ ErrorNumber ReadCatalog()
+ {
+ var catalogMs = new MemoryStream();
+ var lba = (ulong)(_vtoc.catalogTrack * _sectorsPerTrack + _vtoc.catalogSector);
+ _totalFileEntries = 0;
+ _catalogCache = new Dictionary();
+ _fileTypeCache = new Dictionary();
+ _lockedFiles = [];
+
+ if(lba == 0 || lba > _device.Info.Sectors) return ErrorNumber.InvalidArgument;
+
+ while(lba != 0)
+ {
+ _usedSectors++;
+ ErrorNumber errno = _device.ReadSector(lba, out byte[] catSectorB, out _);
+
+ if(errno != ErrorNumber.NoError) return errno;
+
+ _totalFileEntries += 7;
+
+ if(_debug) catalogMs.Write(catSectorB, 0, catSectorB.Length);
+
+ // Read the catalog sector
+ CatalogSector catSector = Marshal.ByteArrayToStructureLittleEndian(catSectorB);
+
+ foreach(FileEntry entry in catSector.entries.Where(entry => entry.extentTrack > 0))
+ {
+ _track1UsedByFiles |= entry.extentTrack == 1;
+ _track2UsedByFiles |= entry.extentTrack == 2;
+
+ var filenameB = new byte[30];
+ var ts = (ushort)(entry.extentTrack << 8 | entry.extentSector);
+
+ // Apple DOS has high byte set over ASCII.
+ for(var i = 0; i < 30; i++) filenameB[i] = (byte)(entry.filename[i] & 0x7F);
+
+ string filename = StringHandlers.SpacePaddedToString(filenameB, _encoding);
+
+ _catalogCache.TryAdd(filename, ts);
+ _fileTypeCache.TryAdd(filename, (byte)(entry.typeAndFlags & 0x7F));
+
+ if((entry.typeAndFlags & 0x80) == 0x80 && !_lockedFiles.Contains(filename)) _lockedFiles.Add(filename);
+ }
+
+ lba = (ulong)(catSector.trackOfNext * _sectorsPerTrack + catSector.sectorOfNext);
+
+ if(lba > _device.Info.Sectors) break;
+ }
+
+ if(_debug) _catalogBlocks = catalogMs.ToArray();
+
+ return ErrorNumber.NoError;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -113,58 +167,4 @@ public sealed partial class AppleDOS
}
#endregion
-
- ErrorNumber ReadCatalog()
- {
- var catalogMs = new MemoryStream();
- var lba = (ulong)(_vtoc.catalogTrack * _sectorsPerTrack + _vtoc.catalogSector);
- _totalFileEntries = 0;
- _catalogCache = new Dictionary();
- _fileTypeCache = new Dictionary();
- _lockedFiles = [];
-
- if(lba == 0 || lba > _device.Info.Sectors) return ErrorNumber.InvalidArgument;
-
- while(lba != 0)
- {
- _usedSectors++;
- ErrorNumber errno = _device.ReadSector(lba, out byte[] catSectorB);
-
- if(errno != ErrorNumber.NoError) return errno;
-
- _totalFileEntries += 7;
-
- if(_debug) catalogMs.Write(catSectorB, 0, catSectorB.Length);
-
- // Read the catalog sector
- CatalogSector catSector = Marshal.ByteArrayToStructureLittleEndian(catSectorB);
-
- foreach(FileEntry entry in catSector.entries.Where(entry => entry.extentTrack > 0))
- {
- _track1UsedByFiles |= entry.extentTrack == 1;
- _track2UsedByFiles |= entry.extentTrack == 2;
-
- var filenameB = new byte[30];
- var ts = (ushort)(entry.extentTrack << 8 | entry.extentSector);
-
- // Apple DOS has high byte set over ASCII.
- for(var i = 0; i < 30; i++) filenameB[i] = (byte)(entry.filename[i] & 0x7F);
-
- string filename = StringHandlers.SpacePaddedToString(filenameB, _encoding);
-
- _catalogCache.TryAdd(filename, ts);
- _fileTypeCache.TryAdd(filename, (byte)(entry.typeAndFlags & 0x7F));
-
- if((entry.typeAndFlags & 0x80) == 0x80 && !_lockedFiles.Contains(filename)) _lockedFiles.Add(filename);
- }
-
- lba = (ulong)(catSector.trackOfNext * _sectorsPerTrack + catSector.sectorOfNext);
-
- if(lba > _device.Info.Sectors) break;
- }
-
- if(_debug) _catalogBlocks = catalogMs.ToArray();
-
- return ErrorNumber.NoError;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs
index 6b6e39921..b83e49175 100644
--- a/Aaru.Filesystems/AppleDOS/File.cs
+++ b/Aaru.Filesystems/AppleDOS/File.cs
@@ -40,6 +40,103 @@ namespace Aaru.Filesystems;
public sealed partial class AppleDOS
{
+ ErrorNumber CacheFile(string path)
+ {
+ string[] pathElements = path.Split(new[]
+ {
+ '/'
+ },
+ StringSplitOptions.RemoveEmptyEntries);
+
+ if(pathElements.Length != 1) return ErrorNumber.NotSupported;
+
+ string filename = pathElements[0].ToUpperInvariant();
+
+ if(filename.Length > 30) return ErrorNumber.NameTooLong;
+
+ if(!_catalogCache.TryGetValue(filename, out ushort ts)) return ErrorNumber.NoSuchFile;
+
+ var lba = (ulong)(((ts & 0xFF00) >> 8) * _sectorsPerTrack + (ts & 0xFF));
+ var fileMs = new MemoryStream();
+ var tsListMs = new MemoryStream();
+ ushort expectedBlock = 0;
+
+ while(lba != 0)
+ {
+ _usedSectors++;
+ ErrorNumber errno = _device.ReadSector(lba, out byte[] tsSectorB, out _);
+
+ if(errno != ErrorNumber.NoError) return errno;
+
+ if(_debug) tsListMs.Write(tsSectorB, 0, tsSectorB.Length);
+
+ // Read the track/sector list sector
+ TrackSectorList tsSector = Marshal.ByteArrayToStructureLittleEndian(tsSectorB);
+
+ if(tsSector.sectorOffset > expectedBlock)
+ {
+ var hole = new byte[(tsSector.sectorOffset - expectedBlock) * _vtoc.bytesPerSector];
+ fileMs.Write(hole, 0, hole.Length);
+ expectedBlock = tsSector.sectorOffset;
+ }
+
+ foreach(TrackSectorListEntry entry in tsSector.entries)
+ {
+ _track1UsedByFiles |= entry.track == 1;
+ _track2UsedByFiles |= entry.track == 2;
+ _usedSectors++;
+
+ var blockLba = (ulong)(entry.track * _sectorsPerTrack + entry.sector);
+
+ if(blockLba == 0) break;
+
+ errno = _device.ReadSector(blockLba, out byte[] fileBlock, out _);
+
+ if(errno != ErrorNumber.NoError) return errno;
+
+ fileMs.Write(fileBlock, 0, fileBlock.Length);
+ expectedBlock++;
+ }
+
+ lba = (ulong)(tsSector.nextListTrack * _sectorsPerTrack + tsSector.nextListSector);
+ }
+
+ if(_fileCache.ContainsKey(filename)) _fileCache.Remove(filename);
+
+ if(_extentCache.ContainsKey(filename)) _extentCache.Remove(filename);
+
+ if(_fileSizeCache.ContainsKey(filename)) _fileSizeCache.Remove(filename);
+
+ _fileCache.Add(filename, fileMs.ToArray());
+ _extentCache.Add(filename, tsListMs.ToArray());
+ _fileSizeCache.Add(filename, (int)fileMs.Length);
+
+ return ErrorNumber.NoError;
+ }
+
+ ErrorNumber CacheAllFiles()
+ {
+ _fileCache = new Dictionary();
+ _extentCache = new Dictionary();
+
+ foreach(ErrorNumber error in _catalogCache.Keys.Select(CacheFile).Where(error => error != ErrorNumber.NoError))
+ return error;
+
+ uint tracksOnBoot = 1;
+
+ if(!_track1UsedByFiles) tracksOnBoot++;
+
+ if(!_track2UsedByFiles) tracksOnBoot++;
+
+ ErrorNumber errno = _device.ReadSectors(0, (uint)(tracksOnBoot * _sectorsPerTrack), out _bootBlocks, out _);
+
+ if(errno != ErrorNumber.NoError) return errno;
+
+ _usedSectors += (uint)(_bootBlocks.Length / _vtoc.bytesPerSector);
+
+ return ErrorNumber.NoError;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -217,101 +314,4 @@ public sealed partial class AppleDOS
}
#endregion
-
- ErrorNumber CacheFile(string path)
- {
- string[] pathElements = path.Split(new[]
- {
- '/'
- },
- StringSplitOptions.RemoveEmptyEntries);
-
- if(pathElements.Length != 1) return ErrorNumber.NotSupported;
-
- string filename = pathElements[0].ToUpperInvariant();
-
- if(filename.Length > 30) return ErrorNumber.NameTooLong;
-
- if(!_catalogCache.TryGetValue(filename, out ushort ts)) return ErrorNumber.NoSuchFile;
-
- var lba = (ulong)(((ts & 0xFF00) >> 8) * _sectorsPerTrack + (ts & 0xFF));
- var fileMs = new MemoryStream();
- var tsListMs = new MemoryStream();
- ushort expectedBlock = 0;
-
- while(lba != 0)
- {
- _usedSectors++;
- ErrorNumber errno = _device.ReadSector(lba, out byte[] tsSectorB);
-
- if(errno != ErrorNumber.NoError) return errno;
-
- if(_debug) tsListMs.Write(tsSectorB, 0, tsSectorB.Length);
-
- // Read the track/sector list sector
- TrackSectorList tsSector = Marshal.ByteArrayToStructureLittleEndian(tsSectorB);
-
- if(tsSector.sectorOffset > expectedBlock)
- {
- var hole = new byte[(tsSector.sectorOffset - expectedBlock) * _vtoc.bytesPerSector];
- fileMs.Write(hole, 0, hole.Length);
- expectedBlock = tsSector.sectorOffset;
- }
-
- foreach(TrackSectorListEntry entry in tsSector.entries)
- {
- _track1UsedByFiles |= entry.track == 1;
- _track2UsedByFiles |= entry.track == 2;
- _usedSectors++;
-
- var blockLba = (ulong)(entry.track * _sectorsPerTrack + entry.sector);
-
- if(blockLba == 0) break;
-
- errno = _device.ReadSector(blockLba, out byte[] fileBlock);
-
- if(errno != ErrorNumber.NoError) return errno;
-
- fileMs.Write(fileBlock, 0, fileBlock.Length);
- expectedBlock++;
- }
-
- lba = (ulong)(tsSector.nextListTrack * _sectorsPerTrack + tsSector.nextListSector);
- }
-
- if(_fileCache.ContainsKey(filename)) _fileCache.Remove(filename);
-
- if(_extentCache.ContainsKey(filename)) _extentCache.Remove(filename);
-
- if(_fileSizeCache.ContainsKey(filename)) _fileSizeCache.Remove(filename);
-
- _fileCache.Add(filename, fileMs.ToArray());
- _extentCache.Add(filename, tsListMs.ToArray());
- _fileSizeCache.Add(filename, (int)fileMs.Length);
-
- return ErrorNumber.NoError;
- }
-
- ErrorNumber CacheAllFiles()
- {
- _fileCache = new Dictionary();
- _extentCache = new Dictionary();
-
- foreach(ErrorNumber error in _catalogCache.Keys.Select(CacheFile).Where(error => error != ErrorNumber.NoError))
- return error;
-
- uint tracksOnBoot = 1;
-
- if(!_track1UsedByFiles) tracksOnBoot++;
-
- if(!_track2UsedByFiles) tracksOnBoot++;
-
- ErrorNumber errno = _device.ReadSectors(0, (uint)(tracksOnBoot * _sectorsPerTrack), out _bootBlocks);
-
- if(errno != ErrorNumber.NoError) return errno;
-
- _usedSectors += (uint)(_bootBlocks.Length / _vtoc.bytesPerSector);
-
- return ErrorNumber.NoError;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/AppleDOS/Info.cs b/Aaru.Filesystems/AppleDOS/Info.cs
index c6325ddbf..4cccda9c3 100644
--- a/Aaru.Filesystems/AppleDOS/Info.cs
+++ b/Aaru.Filesystems/AppleDOS/Info.cs
@@ -48,7 +48,7 @@ public sealed partial class AppleDOS
int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
- ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB);
+ ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -70,7 +70,7 @@ public sealed partial class AppleDOS
int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
- ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB);
+ ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs
index 184631155..924738009 100644
--- a/Aaru.Filesystems/AppleDOS/Super.cs
+++ b/Aaru.Filesystems/AppleDOS/Super.cs
@@ -75,7 +75,7 @@ public sealed partial class AppleDOS
_sectorsPerTrack = _device.Info.Sectors == 455 ? 13 : 16;
// Read the VTOC
- ErrorNumber error = _device.ReadSector((ulong)(17 * _sectorsPerTrack), out _vtocBlocks);
+ ErrorNumber error = _device.ReadSector((ulong)(17 * _sectorsPerTrack), out _vtocBlocks, out _);
if(error != ErrorNumber.NoError) return error;
diff --git a/Aaru.Filesystems/AppleHFS/Info.cs b/Aaru.Filesystems/AppleHFS/Info.cs
index c3760d593..b2c55c167 100644
--- a/Aaru.Filesystems/AppleHFS/Info.cs
+++ b/Aaru.Filesystems/AppleHFS/Info.cs
@@ -54,7 +54,7 @@ public sealed partial class AppleHFS
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)
{
- errno = imagePlugin.ReadSectors(partition.Start, 2, out mdbSector);
+ errno = imagePlugin.ReadSectors(partition.Start, 2, out mdbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -74,7 +74,7 @@ public sealed partial class AppleHFS
}
else
{
- errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector);
+ errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -111,7 +111,7 @@ public sealed partial class AppleHFS
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)
{
- errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmpSector);
+ errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmpSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -139,7 +139,7 @@ public sealed partial class AppleHFS
}
else
{
- errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector);
+ errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -147,7 +147,7 @@ public sealed partial class AppleHFS
if(drSigWord == AppleCommon.HFS_MAGIC)
{
- errno = imagePlugin.ReadSector(partition.Start, out bbSector);
+ errno = imagePlugin.ReadSector(partition.Start, out bbSector, out _);
if(errno != ErrorNumber.NoError) return;
}
diff --git a/Aaru.Filesystems/AppleHFSPlus/Info.cs b/Aaru.Filesystems/AppleHFSPlus/Info.cs
index bdb862050..70bdee154 100644
--- a/Aaru.Filesystems/AppleHFSPlus/Info.cs
+++ b/Aaru.Filesystems/AppleHFSPlus/Info.cs
@@ -54,7 +54,7 @@ public sealed partial class AppleHFSPlus
if(0x800 % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -85,7 +85,8 @@ public sealed partial class AppleHFSPlus
errno = imagePlugin.ReadSectors(partition.Start + hfspOffset,
sectorsToRead,
- out vhSector); // Read volume header
+ out vhSector,
+ out _); // Read volume header
if(errno != ErrorNumber.NoError) return false;
@@ -110,7 +111,7 @@ public sealed partial class AppleHFSPlus
if(0x800 % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -146,7 +147,8 @@ public sealed partial class AppleHFSPlus
errno = imagePlugin.ReadSectors(partition.Start + hfspOffset,
sectorsToRead,
- out vhSector); // Read volume header
+ out vhSector,
+ out _); // Read volume header
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs
index 5a2a2306a..6c805161d 100644
--- a/Aaru.Filesystems/AppleMFS/File.cs
+++ b/Aaru.Filesystems/AppleMFS/File.cs
@@ -40,6 +40,112 @@ namespace Aaru.Filesystems;
// Information from Inside Macintosh Volume II
public sealed partial class AppleMFS
{
+ ErrorNumber ReadFile(string path, out byte[] buf, bool resourceFork, bool tags)
+ {
+ buf = null;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ string[] pathElements = path.Split(new[]
+ {
+ '/'
+ },
+ StringSplitOptions.RemoveEmptyEntries);
+
+ if(pathElements.Length != 1) return ErrorNumber.NotSupported;
+
+ path = pathElements[0];
+
+ if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile;
+
+ if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile;
+
+ uint nextBlock;
+
+ if(resourceFork)
+ {
+ if(entry.flRPyLen == 0)
+ {
+ buf = [];
+
+ return ErrorNumber.NoError;
+ }
+
+ nextBlock = entry.flRStBlk;
+ }
+ else
+ {
+ if(entry.flPyLen == 0)
+ {
+ buf = [];
+
+ return ErrorNumber.NoError;
+ }
+
+ nextBlock = entry.flStBlk;
+ }
+
+ var ms = new MemoryStream();
+
+ do
+ {
+ ErrorNumber errno = tags
+ ? _device.ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) +
+ _volMdb.drAlBlSt +
+ _partitionStart,
+ (uint)_sectorsPerBlock,
+ SectorTagType.AppleSonyTag,
+ out byte[] sectors)
+ : _device.ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) +
+ _volMdb.drAlBlSt +
+ _partitionStart,
+ (uint)_sectorsPerBlock,
+ out sectors,
+ out _);
+
+ if(errno != ErrorNumber.NoError) return errno;
+
+ ms.Write(sectors, 0, sectors.Length);
+
+ if(_blockMap[nextBlock] == BMAP_FREE)
+ {
+ AaruLogging.Error(Localization.File_truncated_at_block_0, nextBlock);
+
+ break;
+ }
+
+ nextBlock = _blockMap[nextBlock];
+ } while(nextBlock > BMAP_LAST);
+
+ if(tags)
+ buf = ms.ToArray();
+ else
+ {
+ if(resourceFork)
+ {
+ if(ms.Length < entry.flRLgLen)
+ buf = ms.ToArray();
+ else
+ {
+ buf = new byte[entry.flRLgLen];
+ Array.Copy(ms.ToArray(), 0, buf, 0, buf.Length);
+ }
+ }
+ else
+ {
+ if(ms.Length < entry.flLgLen)
+ buf = ms.ToArray();
+ else
+ {
+ buf = new byte[entry.flLgLen];
+ Array.Copy(ms.ToArray(), 0, buf, 0, buf.Length);
+ }
+ }
+ }
+
+ return ErrorNumber.NoError;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -270,109 +376,4 @@ public sealed partial class AppleMFS
}
#endregion
-
- ErrorNumber ReadFile(string path, out byte[] buf, bool resourceFork, bool tags)
- {
- buf = null;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- string[] pathElements = path.Split(new[]
- {
- '/'
- },
- StringSplitOptions.RemoveEmptyEntries);
-
- if(pathElements.Length != 1) return ErrorNumber.NotSupported;
-
- path = pathElements[0];
-
- if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile;
-
- if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile;
-
- uint nextBlock;
-
- if(resourceFork)
- {
- if(entry.flRPyLen == 0)
- {
- buf = [];
-
- return ErrorNumber.NoError;
- }
-
- nextBlock = entry.flRStBlk;
- }
- else
- {
- if(entry.flPyLen == 0)
- {
- buf = [];
-
- return ErrorNumber.NoError;
- }
-
- nextBlock = entry.flStBlk;
- }
-
- var ms = new MemoryStream();
-
- do
- {
- ErrorNumber errno = tags
- ? _device.ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) +
- _volMdb.drAlBlSt +
- _partitionStart,
- (uint)_sectorsPerBlock,
- SectorTagType.AppleSonyTag,
- out byte[] sectors)
- : _device.ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) +
- _volMdb.drAlBlSt +
- _partitionStart,
- (uint)_sectorsPerBlock,
- out sectors);
-
- if(errno != ErrorNumber.NoError) return errno;
-
- ms.Write(sectors, 0, sectors.Length);
-
- if(_blockMap[nextBlock] == BMAP_FREE)
- {
- AaruLogging.Error(Localization.File_truncated_at_block_0, nextBlock);
-
- break;
- }
-
- nextBlock = _blockMap[nextBlock];
- } while(nextBlock > BMAP_LAST);
-
- if(tags)
- buf = ms.ToArray();
- else
- {
- if(resourceFork)
- {
- if(ms.Length < entry.flRLgLen)
- buf = ms.ToArray();
- else
- {
- buf = new byte[entry.flRLgLen];
- Array.Copy(ms.ToArray(), 0, buf, 0, buf.Length);
- }
- }
- else
- {
- if(ms.Length < entry.flLgLen)
- buf = ms.ToArray();
- else
- {
- buf = new byte[entry.flLgLen];
- Array.Copy(ms.ToArray(), 0, buf, 0, buf.Length);
- }
- }
- }
-
- return ErrorNumber.NoError;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/AppleMFS/Info.cs b/Aaru.Filesystems/AppleMFS/Info.cs
index 965b2a851..4b8e6aad7 100644
--- a/Aaru.Filesystems/AppleMFS/Info.cs
+++ b/Aaru.Filesystems/AppleMFS/Info.cs
@@ -48,7 +48,7 @@ public sealed partial class AppleMFS
{
if(2 + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -69,11 +69,11 @@ public sealed partial class AppleMFS
var mdb = new MasterDirectoryBlock();
- ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector, out _);
if(errno != ErrorNumber.NoError) return;
- errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bbSector);
+ errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bbSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs
index 8179df106..06f5dbf1c 100644
--- a/Aaru.Filesystems/AppleMFS/Super.cs
+++ b/Aaru.Filesystems/AppleMFS/Super.cs
@@ -59,11 +59,11 @@ public sealed partial class AppleMFS
_volMdb = new MasterDirectoryBlock();
- ErrorNumber errno = _device.ReadSector(2 + _partitionStart, out _mdbBlocks);
+ ErrorNumber errno = _device.ReadSector(2 + _partitionStart, out _mdbBlocks, out _);
if(errno != ErrorNumber.NoError) return errno;
- errno = _device.ReadSector(0 + _partitionStart, out _bootBlocks);
+ errno = _device.ReadSector(0 + _partitionStart, out _bootBlocks, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -88,7 +88,7 @@ public sealed partial class AppleMFS
Array.Copy(_mdbBlocks, 0x024, variableSize, 0, _volMdb.drVNSiz + 1);
_volMdb.drVN = StringHandlers.PascalToString(variableSize, _encoding);
- errno = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, out _directoryBlocks);
+ errno = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, out _directoryBlocks, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -98,7 +98,7 @@ public sealed partial class AppleMFS
int sectorsInWholeMdb = bytesInWholeMdb / (int)_device.Info.SectorSize +
bytesInWholeMdb % (int)_device.Info.SectorSize;
- errno = _device.ReadSectors(_partitionStart + 2, (uint)sectorsInWholeMdb, out byte[] wholeMdb);
+ errno = _device.ReadSectors(_partitionStart + 2, (uint)sectorsInWholeMdb, out byte[] wholeMdb, out _);
if(errno != ErrorNumber.NoError) return errno;
diff --git a/Aaru.Filesystems/AtheOS/Info.cs b/Aaru.Filesystems/AtheOS/Info.cs
index b104a43bc..f160cd7f1 100644
--- a/Aaru.Filesystems/AtheOS/Info.cs
+++ b/Aaru.Filesystems/AtheOS/Info.cs
@@ -55,7 +55,7 @@ public sealed partial class AtheOS
if(sector + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp);
+ ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -86,7 +86,7 @@ public sealed partial class AtheOS
if(imagePlugin.Info.SectorSize < AFS_SUPERBLOCK_SIZE) run = AFS_SUPERBLOCK_SIZE / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp);
+ ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/BFS/Info.cs b/Aaru.Filesystems/BFS/Info.cs
index d6cf0f258..acbc4ea3f 100644
--- a/Aaru.Filesystems/BFS/Info.cs
+++ b/Aaru.Filesystems/BFS/Info.cs
@@ -50,7 +50,7 @@ public sealed partial class BeFS
{
if(2 + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -67,7 +67,7 @@ public sealed partial class BeFS
if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) return true;
- errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector);
+ errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -89,7 +89,7 @@ public sealed partial class BeFS
var besb = new SuperBlock();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -101,7 +101,7 @@ public sealed partial class BeFS
littleEndian = besb.magic1 == BEFS_CIGAM1;
else
{
- errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector);
+ errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -111,7 +111,7 @@ public sealed partial class BeFS
littleEndian = besb.magic1 == BEFS_CIGAM1;
else if(sbSector.Length >= 0x400)
{
- errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] temp);
+ errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] temp, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/BTRFS/Info.cs b/Aaru.Filesystems/BTRFS/Info.cs
index 2b92d2f8d..33956ed43 100644
--- a/Aaru.Filesystems/BTRFS/Info.cs
+++ b/Aaru.Filesystems/BTRFS/Info.cs
@@ -58,7 +58,8 @@ public sealed partial class BTRFS
if(sbSectorOff + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector);
+ ErrorNumber errno =
+ imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -94,7 +95,8 @@ public sealed partial class BTRFS
ulong sbSectorOff = 0x10000 / imagePlugin.Info.SectorSize;
uint sbSectorSize = 0x1000 / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector);
+ ErrorNumber errno =
+ imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/CBM/Info.cs b/Aaru.Filesystems/CBM/Info.cs
index 989c7410f..4663e9c12 100644
--- a/Aaru.Filesystems/CBM/Info.cs
+++ b/Aaru.Filesystems/CBM/Info.cs
@@ -61,7 +61,7 @@ public sealed partial class CBM
if(imagePlugin.Info.Sectors == 3200)
{
- ErrorNumber errno = imagePlugin.ReadSector(1560, out sector);
+ ErrorNumber errno = imagePlugin.ReadSector(1560, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -71,7 +71,7 @@ public sealed partial class CBM
}
else
{
- ErrorNumber errno = imagePlugin.ReadSector(357, out sector);
+ ErrorNumber errno = imagePlugin.ReadSector(357, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -105,7 +105,7 @@ public sealed partial class CBM
if(imagePlugin.Info.Sectors == 3200)
{
- ErrorNumber errno = imagePlugin.ReadSector(1560, out sector);
+ ErrorNumber errno = imagePlugin.ReadSector(1560, out sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -147,7 +147,7 @@ public sealed partial class CBM
}
else
{
- ErrorNumber errno = imagePlugin.ReadSector(357, out sector);
+ ErrorNumber errno = imagePlugin.ReadSector(357, out sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/CBM/Super.cs b/Aaru.Filesystems/CBM/Super.cs
index 198d845ae..a73d0ea31 100644
--- a/Aaru.Filesystems/CBM/Super.cs
+++ b/Aaru.Filesystems/CBM/Super.cs
@@ -84,7 +84,7 @@ public sealed partial class CBM
// Commodore 1581
if(imagePlugin.Info.Sectors == 3200)
{
- ErrorNumber errno = imagePlugin.ReadSector(1560, out _diskHeader);
+ ErrorNumber errno = imagePlugin.ReadSector(1560, out _diskHeader, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -96,7 +96,7 @@ public sealed partial class CBM
_bam = new byte[512];
// Got to first BAM sector
- errno = imagePlugin.ReadSector(1561, out sector);
+ errno = imagePlugin.ReadSector(1561, out sector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -105,7 +105,7 @@ public sealed partial class CBM
if(_bam[0] > 0)
{
// Got to next (and last) BAM sector
- errno = imagePlugin.ReadSector((ulong)((_bam[0] - 1) * 40), out sector);
+ errno = imagePlugin.ReadSector((ulong)((_bam[0] - 1) * 40), out sector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -122,7 +122,7 @@ public sealed partial class CBM
}
else
{
- ErrorNumber errno = imagePlugin.ReadSector(357, out _bam);
+ ErrorNumber errno = imagePlugin.ReadSector(357, out _bam, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -147,7 +147,7 @@ public sealed partial class CBM
do
{
- ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector);
+ ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -241,8 +241,9 @@ public sealed partial class CBM
_statfs.FreeFiles--;
for(var i = 0; i < dirEntry.name.Length; i++)
- if(dirEntry.name[i] == 0xA0)
- dirEntry.name[i] = 0;
+ {
+ if(dirEntry.name[i] == 0xA0) dirEntry.name[i] = 0;
+ }
string name = StringHandlers.CToString(dirEntry.name, encoding);
@@ -262,7 +263,7 @@ public sealed partial class CBM
{
if(dirEntry.firstFileBlockTrack == 0) break;
- ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector);
+ ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector, out _);
if(errno != ErrorNumber.NoError) break;
diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs
index c9d545997..122ac7011 100644
--- a/Aaru.Filesystems/CPM/Info.cs
+++ b/Aaru.Filesystems/CPM/Info.cs
@@ -181,15 +181,15 @@ public sealed partial class CPM
if(!_cpmFound)
{
// Read CHS = {0,0,1}
- errno = imagePlugin.ReadSector(0 + partition.Start, out sector);
+ errno = imagePlugin.ReadSector(0 + partition.Start, out sector, out _);
if(errno == ErrorNumber.NoError)
{
- int amsSbOffset = 0;
+ var amsSbOffset = 0;
- uint sig1 = BitConverter.ToUInt32(sector, 0x2B);
+ var sig1 = BitConverter.ToUInt32(sector, 0x2B);
uint sig2 = BitConverter.ToUInt32(sector, 0x33) & 0x00FFFFFF;
- uint sig3 = BitConverter.ToUInt32(sector, 0x7C);
+ var sig3 = BitConverter.ToUInt32(sector, 0x7C);
// PCW16 extended boot record
if(sig1 == 0x4D2F5043 && sig2 == 0x004B5344 && sig3 == sig1) amsSbOffset = 0x80;
@@ -204,8 +204,8 @@ public sealed partial class CPM
amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2)
{
// Calculate device limits
- ulong sides = (ulong)(amsSb.format == 0 ? 1 : 2);
- ulong sectorCount = (ulong)(amsSb.tps * amsSb.spt * (byte)sides);
+ var sides = (ulong)(amsSb.format == 0 ? 1 : 2);
+ var sectorCount = (ulong)(amsSb.tps * amsSb.spt * (byte)sides);
sectorSize = (ulong)(128 << amsSb.psh);
// Compare device limits from superblock to real limits
@@ -222,7 +222,7 @@ public sealed partial class CPM
bsh = amsSb.bsh
};
- for(int i = 0; i < _dpb.bsh; i++) _dpb.blm += (byte)Math.Pow(2, i);
+ for(var i = 0; i < _dpb.bsh; i++) _dpb.blm += (byte)Math.Pow(2, i);
if(sectorCount >= 1440)
{
@@ -240,14 +240,15 @@ public sealed partial class CPM
_dpb.off = amsSb.off;
_dpb.psh = amsSb.psh;
- for(int i = 0; i < _dpb.psh; i++) _dpb.phm += (byte)Math.Pow(2, i);
+ for(var i = 0; i < _dpb.psh; i++) _dpb.phm += (byte)Math.Pow(2, i);
- _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128));
- uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize);
+ _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128));
+ var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize);
imagePlugin.ReadSectors(firstDirectorySector + partition.Start,
directoryLength,
- out directory);
+ out directory,
+ out _);
// Build a CP/M disk definition
_workingDefinition = new CpmDefinition
@@ -275,7 +276,7 @@ public sealed partial class CPM
}
};
- for(int si = 0; si < amsSb.spt; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < amsSb.spt; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
if(amsSb.format == 2)
{
@@ -292,7 +293,7 @@ public sealed partial class CPM
sectorIds = new int[amsSb.spt]
};
- for(int si = 0; si < amsSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < amsSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
else
_workingDefinition.order = null;
@@ -310,14 +311,14 @@ public sealed partial class CPM
if(!_cpmFound)
{
// Read CHS = {0,0,4}
- errno = imagePlugin.ReadSector(3 + partition.Start, out sector);
+ errno = imagePlugin.ReadSector(3 + partition.Start, out sector, out _);
if(errno == ErrorNumber.NoError)
{
ushort sum = 0;
// Sum of all 16-bit words that make this sector must be 0
- for(int i = 0; i < sector.Length; i += 2) sum += BitConverter.ToUInt16(sector, i);
+ for(var i = 0; i < sector.Length; i += 2) sum += BitConverter.ToUInt16(sector, i);
// It may happen that there is a corrupted superblock
// Better to ignore corrupted than to false positive the rest
@@ -328,9 +329,9 @@ public sealed partial class CPM
// Calculate volume size
sectorSize = (ulong)(hddSb.recordsPerSector * 128);
- ulong sectorsInPartition = (ulong)(hddSb.cylinders * hddSb.heads * hddSb.sectorsPerTrack);
+ var sectorsInPartition = (ulong)(hddSb.cylinders * hddSb.heads * hddSb.sectorsPerTrack);
- ulong startingSector =
+ var startingSector =
(ulong)((hddSb.firstCylinder * hddSb.heads + hddSb.heads) * hddSb.sectorsPerTrack);
// If volume size corresponds with working partition (this variant will be inside MBR partitioning)
@@ -362,11 +363,12 @@ public sealed partial class CPM
spt = hddSb.spt
};
- uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize);
+ var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize);
imagePlugin.ReadSectors(firstDirectorySector + partition.Start,
directoryLength,
- out directory);
+ out directory,
+ out _);
AaruLogging.Debug(MODULE_NAME, Localization.Found_CPM_86_hard_disk_superblock);
@@ -404,10 +406,10 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < hddSb.sectorsPerTrack; si++)
+ for(var si = 0; si < hddSb.sectorsPerTrack; si++)
_workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < hddSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < hddSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
}
}
@@ -417,7 +419,7 @@ public sealed partial class CPM
if(!_cpmFound)
{
// Read CHS = {0,0,1}
- errno = imagePlugin.ReadSector(0 + partition.Start, out sector);
+ errno = imagePlugin.ReadSector(0 + partition.Start, out sector, out _);
if(errno == ErrorNumber.NoError)
{
@@ -492,7 +494,7 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
}
break;
@@ -551,9 +553,9 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < 8; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < 8; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
break;
@@ -614,9 +616,9 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
break;
@@ -676,9 +678,9 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
break;
@@ -737,9 +739,9 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
break;
@@ -798,9 +800,9 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 15; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 15; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < 15; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < 15; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
break;
@@ -859,9 +861,9 @@ public sealed partial class CPM
sofs = 0
};
- for(int si = 0; si < 18; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
+ for(var si = 0; si < 18; si++) _workingDefinition.side1.sectorIds[si] = si + 1;
- for(int si = 0; si < 18; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
+ for(var si = 0; si < 18; si++) _workingDefinition.side2.sectorIds[si] = si + 1;
}
break;
@@ -869,11 +871,12 @@ public sealed partial class CPM
if(_cpmFound)
{
- uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize);
+ var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize);
imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start,
directoryLength,
- out directory);
+ out directory,
+ out _);
AaruLogging.Debug(MODULE_NAME, Localization.Found_CPM_86_floppy_identifier);
}
@@ -924,7 +927,7 @@ public sealed partial class CPM
{
_sectorMask = new int[def.side1.sectorIds.Length];
- for(int m = 0; m < _sectorMask.Length; m++)
+ for(var m = 0; m < _sectorMask.Length; m++)
_sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0];
}
else
@@ -934,11 +937,11 @@ public sealed partial class CPM
{
_sectorMask = new int[def.side1.sectorIds.Length + def.side2.sectorIds.Length];
- for(int m = 0; m < def.side1.sectorIds.Length; m++)
+ for(var m = 0; m < def.side1.sectorIds.Length; m++)
_sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0];
// Skip first track (first side)
- for(int m = 0; m < def.side2.sectorIds.Length; m++)
+ for(var m = 0; m < def.side2.sectorIds.Length; m++)
{
_sectorMask[m + def.side1.sectorIds.Length] =
def.side2.sectorIds[m] - def.side2.sectorIds[0] + def.side1.sectorIds.Length;
@@ -951,11 +954,11 @@ public sealed partial class CPM
StringComparison.InvariantCultureIgnoreCase) ==
0)
{
- for(int m = 0; m < def.side1.sectorIds.Length; m++)
+ for(var m = 0; m < def.side1.sectorIds.Length; m++)
_sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0];
// Skip first track (first side) and first track (second side)
- for(int m = 0; m < def.side1.sectorIds.Length; m++)
+ for(var m = 0; m < def.side1.sectorIds.Length; m++)
{
_sectorMask[m + def.side1.sectorIds.Length] =
def.side1.sectorIds[m] -
@@ -1001,13 +1004,14 @@ public sealed partial class CPM
// Read the directory marked by this definition
var ms = new MemoryStream();
- for(int p = 0; p < dirLen; p++)
+ for(var p = 0; p < dirLen; p++)
{
errno = imagePlugin.ReadSector((ulong)((int)offset +
(int)partition.Start +
p / _sectorMask.Length * _sectorMask.Length +
_sectorMask[p % _sectorMask.Length]),
- out byte[] dirSector);
+ out byte[] dirSector,
+ out _);
if(errno != ErrorNumber.NoError) break;
@@ -1025,9 +1029,8 @@ public sealed partial class CPM
// Complement of the directory bytes if needed
if(def.complement)
- {
- for(int b = 0; b < directory.Length; b++) directory[b] = (byte)(~directory[b] & 0xFF);
- }
+ for(var b = 0; b < directory.Length; b++)
+ directory[b] = (byte)(~directory[b] & 0xFF);
// Check the directory
if(CheckDir(directory))
diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs
index bf7b8eef3..81b0f8f9f 100644
--- a/Aaru.Filesystems/CPM/Super.cs
+++ b/Aaru.Filesystems/CPM/Super.cs
@@ -69,7 +69,7 @@ public sealed partial class CPM
{
_sectorMask = new int[_workingDefinition.side1.sectorIds.Length];
- for(int m = 0; m < _sectorMask.Length; m++)
+ for(var m = 0; m < _sectorMask.Length; m++)
_sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0];
}
else
@@ -80,11 +80,11 @@ public sealed partial class CPM
_sectorMask = new int[_workingDefinition.side1.sectorIds.Length +
_workingDefinition.side2.sectorIds.Length];
- for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++)
+ for(var m = 0; m < _workingDefinition.side1.sectorIds.Length; m++)
_sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0];
// Skip first track (first side)
- for(int m = 0; m < _workingDefinition.side2.sectorIds.Length; m++)
+ for(var m = 0; m < _workingDefinition.side2.sectorIds.Length; m++)
{
_sectorMask[m + _workingDefinition.side1.sectorIds.Length] =
_workingDefinition.side2.sectorIds[m] -
@@ -99,11 +99,11 @@ public sealed partial class CPM
StringComparison.InvariantCultureIgnoreCase) ==
0)
{
- for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++)
+ for(var m = 0; m < _workingDefinition.side1.sectorIds.Length; m++)
_sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0];
// Skip first track (first side) and first track (second side)
- for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++)
+ for(var m = 0; m < _workingDefinition.side1.sectorIds.Length; m++)
{
_sectorMask[m + _workingDefinition.side1.sectorIds.Length] =
_workingDefinition.side1.sectorIds[m] -
@@ -123,8 +123,8 @@ public sealed partial class CPM
0)
{
AaruLogging.Debug(MODULE_NAME,
- Localization
- .Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition);
+ Localization
+ .Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition);
return ErrorNumber.NotImplemented;
}
@@ -133,16 +133,16 @@ public sealed partial class CPM
else if(string.Compare(_workingDefinition.order, "EAGLE", StringComparison.InvariantCultureIgnoreCase) == 0)
{
AaruLogging.Debug(MODULE_NAME,
- Localization
- .Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition);
+ Localization
+ .Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition);
return ErrorNumber.NotImplemented;
}
else
{
AaruLogging.Debug(MODULE_NAME,
- Localization.Unknown_order_type_0_not_proceeding_with_this_definition,
- _workingDefinition.order);
+ Localization.Unknown_order_type_0_not_proceeding_with_this_definition,
+ _workingDefinition.order);
return ErrorNumber.NotSupported;
}
@@ -156,19 +156,21 @@ public sealed partial class CPM
{
AaruLogging.Debug(MODULE_NAME, Localization.Deinterleaving_whole_volume);
- for(int p = 0; p <= (int)(partition.End - partition.Start); p++)
+ for(var p = 0; p <= (int)(partition.End - partition.Start); p++)
{
ErrorNumber errno =
_device.ReadSector((ulong)((int)partition.Start +
p / _sectorMask.Length * _sectorMask.Length +
_sectorMask[p % _sectorMask.Length]),
- out byte[] readSector);
+ out byte[] readSector,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
if(_workingDefinition.complement)
- for(int b = 0; b < readSector.Length; b++)
- readSector[b] = (byte)(~readSector[b] & 0xFF);
+ {
+ for(var b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF);
+ }
deinterleavedSectors.Add((ulong)p, readSector);
}
@@ -177,7 +179,7 @@ public sealed partial class CPM
int blockSize = 128 << _dpb.bsh;
var blockMs = new MemoryStream();
ulong blockNo = 0;
- int sectorsPerBlock = 0;
+ var sectorsPerBlock = 0;
Dictionary allocationBlocks = new();
AaruLogging.Debug(MODULE_NAME, Localization.Creating_allocation_blocks);
@@ -190,9 +192,9 @@ public sealed partial class CPM
// May it happen? Just in case, CP/M blocks are smaller than physical sectors
if(sector.Length > blockSize)
{
- for(int i = 0; i < sector.Length / blockSize; i++)
+ for(var i = 0; i < sector.Length / blockSize; i++)
{
- byte[] tmp = new byte[blockSize];
+ var tmp = new byte[blockSize];
Array.Copy(sector, blockSize * i, tmp, 0, blockSize);
allocationBlocks.Add(blockNo++, tmp);
}
@@ -229,7 +231,7 @@ public sealed partial class CPM
// Read the whole directory blocks
var dirMs = new MemoryStream();
- for(int d = 0; d < dirSectors; d++)
+ for(var d = 0; d < dirSectors; d++)
{
deinterleavedSectors.TryGetValue((ulong)(d + dirOff), out byte[] sector);
dirMs.Write(sector, 0, sector.Length);
@@ -239,7 +241,7 @@ public sealed partial class CPM
if(directory == null) return ErrorNumber.InvalidArgument;
- int dirCnt = 0;
+ var dirCnt = 0;
string file1 = null;
string file2 = null;
string file3 = null;
@@ -248,7 +250,7 @@ public sealed partial class CPM
_statCache = new Dictionary();
_cpmStat = new FileSystemInfo();
- bool atime = false;
+ var atime = false;
_dirList = [];
_labelCreationDate = null;
_labelUpdateDate = null;
@@ -257,7 +259,7 @@ public sealed partial class CPM
AaruLogging.Debug(MODULE_NAME, Localization.Traversing_directory);
// For each directory entry
- for(int dOff = 0; dOff < directory.Length; dOff += 32)
+ for(var dOff = 0; dOff < directory.Length; dOff += 32)
{
switch(directory[dOff] & 0x7F)
@@ -275,15 +277,15 @@ public sealed partial class CPM
//bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80;
int user = entry.statusUser & 0x0F;
- bool validEntry = true;
+ var validEntry = true;
- for(int i = 0; i < 8; i++)
+ for(var i = 0; i < 8; i++)
{
entry.filename[i] &= 0x7F;
validEntry &= entry.filename[i] >= 0x20;
}
- for(int i = 0; i < 3; i++)
+ for(var i = 0; i < 3; i++)
{
entry.extension[i] &= 0x7F;
validEntry &= entry.extension[i] >= 0x20;
@@ -383,15 +385,15 @@ public sealed partial class CPM
//bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80;
int user = entry.statusUser & 0x0F;
- bool validEntry = true;
+ var validEntry = true;
- for(int i = 0; i < 8; i++)
+ for(var i = 0; i < 8; i++)
{
entry.filename[i] &= 0x7F;
validEntry &= entry.filename[i] >= 0x20;
}
- for(int i = 0; i < 3; i++)
+ for(var i = 0; i < 3; i++)
{
entry.extension[i] &= 0x7F;
validEntry &= entry.extension[i] >= 0x20;
@@ -487,9 +489,9 @@ public sealed partial class CPM
int user = entry.userNumber & 0x0F;
- for(int i = 0; i < 8; i++) entry.filename[i] &= 0x7F;
+ for(var i = 0; i < 8; i++) entry.filename[i] &= 0x7F;
- for(int i = 0; i < 3; i++) entry.extension[i] &= 0x7F;
+ for(var i = 0; i < 3; i++) entry.extension[i] &= 0x7F;
string filename = Encoding.ASCII.GetString(entry.filename).Trim();
string extension = Encoding.ASCII.GetString(entry.extension).Trim();
@@ -505,7 +507,7 @@ public sealed partial class CPM
if(_passwordCache.ContainsKey(filename)) _passwordCache.Remove(filename);
// Copy whole password entry
- byte[] tmp = new byte[32];
+ var tmp = new byte[32];
Array.Copy(directory, dOff, tmp, 0, 32);
_passwordCache.Add(filename, tmp);
@@ -654,7 +656,7 @@ public sealed partial class CPM
else
fInfo = new FileEntryInfo();
- byte[] ctime = new byte[4];
+ var ctime = new byte[4];
ctime[0] = trdPartyDateEntry.create1[0];
ctime[1] = trdPartyDateEntry.create1[1];
@@ -672,7 +674,7 @@ public sealed partial class CPM
else
fInfo = new FileEntryInfo();
- byte[] ctime = new byte[4];
+ var ctime = new byte[4];
ctime[0] = trdPartyDateEntry.create2[0];
ctime[1] = trdPartyDateEntry.create2[1];
@@ -690,7 +692,7 @@ public sealed partial class CPM
else
fInfo = new FileEntryInfo();
- byte[] ctime = new byte[4];
+ var ctime = new byte[4];
ctime[0] = trdPartyDateEntry.create3[0];
ctime[1] = trdPartyDateEntry.create3[1];
@@ -730,7 +732,7 @@ public sealed partial class CPM
if(fileExtents.TryGetValue(filename, out Dictionary> extents))
{
- for(int ex = 0; ex < extents.Count; ex++)
+ for(var ex = 0; ex < extents.Count; ex++)
{
if(!extents.TryGetValue(ex, out List alBlks)) continue;
@@ -759,10 +761,10 @@ public sealed partial class CPM
// For each stored password, store a decoded version of it
foreach(KeyValuePair kvp in _passwordCache)
{
- byte[] tmp = new byte[8];
+ var tmp = new byte[8];
Array.Copy(kvp.Value, 16, tmp, 0, 8);
- for(int t = 0; t < 8; t++) tmp[t] ^= kvp.Value[13];
+ for(var t = 0; t < 8; t++) tmp[t] ^= kvp.Value[13];
_decodedPasswordCache.Add(kvp.Key, tmp);
}
diff --git a/Aaru.Filesystems/Cram/Info.cs b/Aaru.Filesystems/Cram/Info.cs
index a965a98a2..a49115f98 100644
--- a/Aaru.Filesystems/Cram/Info.cs
+++ b/Aaru.Filesystems/Cram/Info.cs
@@ -51,7 +51,7 @@ public sealed partial class Cram
{
if(partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -66,7 +66,7 @@ public sealed partial class Cram
{
encoding ??= Encoding.GetEncoding("iso-8859-15");
information = "";
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
metadata = new FileSystem();
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/ECMA67/Info.cs b/Aaru.Filesystems/ECMA67/Info.cs
index 439cfce60..0f5044084 100644
--- a/Aaru.Filesystems/ECMA67/Info.cs
+++ b/Aaru.Filesystems/ECMA67/Info.cs
@@ -53,7 +53,7 @@ public sealed partial class ECMA67
if(partition.End < 8) return false;
- ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -70,7 +70,7 @@ public sealed partial class ECMA67
{
information = "";
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/EFS/Info.cs b/Aaru.Filesystems/EFS/Info.cs
index 7c1f7e86e..99f0636b3 100644
--- a/Aaru.Filesystems/EFS/Info.cs
+++ b/Aaru.Filesystems/EFS/Info.cs
@@ -51,38 +51,38 @@ public sealed partial class EFS
// Misaligned
if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc)
{
- uint sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize);
if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
if(sector.Length < Marshal.SizeOf()) return false;
- byte[] sbpiece = new byte[Marshal.SizeOf()];
+ var sbpiece = new byte[Marshal.SizeOf()];
Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf());
Superblock sb = Marshal.ByteArrayToStructureBigEndian(sbpiece);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_expected_2_or_3,
- 0x200,
- sb.sb_magic,
- EFS_MAGIC,
- EFS_MAGIC_NEW);
+ Localization.magic_at_0_equals_1_expected_2_or_3,
+ 0x200,
+ sb.sb_magic,
+ EFS_MAGIC,
+ EFS_MAGIC_NEW);
if(sb.sb_magic is EFS_MAGIC or EFS_MAGIC_NEW) return true;
}
else
{
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -91,11 +91,11 @@ public sealed partial class EFS
Superblock sb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_expected_2_or_3,
- 1,
- sb.sb_magic,
- EFS_MAGIC,
- EFS_MAGIC_NEW);
+ Localization.magic_at_0_equals_1_expected_2_or_3,
+ 1,
+ sb.sb_magic,
+ EFS_MAGIC,
+ EFS_MAGIC_NEW);
if(sb.sb_magic is EFS_MAGIC or EFS_MAGIC_NEW) return true;
}
@@ -118,36 +118,36 @@ public sealed partial class EFS
// Misaligned
if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc)
{
- uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize);
if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
if(sector.Length < Marshal.SizeOf()) return;
- byte[] sbpiece = new byte[Marshal.SizeOf()];
+ var sbpiece = new byte[Marshal.SizeOf()];
Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf());
efsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_X3_equals_1_expected_2_or_3,
- 0x200,
- efsSb.sb_magic,
- EFS_MAGIC,
- EFS_MAGIC_NEW);
+ Localization.magic_at_0_X3_equals_1_expected_2_or_3,
+ 0x200,
+ efsSb.sb_magic,
+ EFS_MAGIC,
+ EFS_MAGIC_NEW);
}
else
{
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -156,11 +156,11 @@ public sealed partial class EFS
efsSb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_expected_2_or_3,
- 1,
- efsSb.sb_magic,
- EFS_MAGIC,
- EFS_MAGIC_NEW);
+ Localization.magic_at_0_equals_1_expected_2_or_3,
+ 1,
+ efsSb.sb_magic,
+ EFS_MAGIC,
+ EFS_MAGIC_NEW);
}
if(efsSb.sb_magic != EFS_MAGIC && efsSb.sb_magic != EFS_MAGIC_NEW) return;
diff --git a/Aaru.Filesystems/F2FS/Info.cs b/Aaru.Filesystems/F2FS/Info.cs
index dc4f1d938..a4563a6ce 100644
--- a/Aaru.Filesystems/F2FS/Info.cs
+++ b/Aaru.Filesystems/F2FS/Info.cs
@@ -58,7 +58,7 @@ public sealed partial class F2FS
if(partition.Start + sbAddr + sbSize >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -86,7 +86,7 @@ public sealed partial class F2FS
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs
index 437b7f85f..636677670 100644
--- a/Aaru.Filesystems/FAT/BPB.cs
+++ b/Aaru.Filesystems/FAT/BPB.cs
@@ -116,15 +116,15 @@ public sealed partial class FAT
var ebpb = new BiosParameterBlockEbpb();
var apricotBpb = new ApricotLabel();
- bool useAtariBpb = false;
- bool useMsxBpb = false;
- bool useDos2Bpb = false;
- bool useDos3Bpb = false;
- bool useDos32Bpb = false;
- bool useDos33Bpb = false;
- bool userShortExtendedBpb = false;
- bool useExtendedBpb = false;
- bool useApricotBpb = false;
+ var useAtariBpb = false;
+ var useMsxBpb = false;
+ var useDos2Bpb = false;
+ var useDos3Bpb = false;
+ var useDos32Bpb = false;
+ var useDos33Bpb = false;
+ var userShortExtendedBpb = false;
+ var useExtendedBpb = false;
+ var useApricotBpb = false;
if(imagePlugin.Info.SectorSize >= 256)
{
@@ -374,10 +374,10 @@ public sealed partial class FAT
byte z80Di = bpbSector[0];
// First FAT1 sector resides at LBA 0x14
- imagePlugin.ReadSector(0x14, out byte[] fat1Sector0);
+ imagePlugin.ReadSector(0x14, out byte[] fat1Sector0, out _);
// First FAT2 sector resides at LBA 0x1A
- imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0);
+ imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0, out _);
bool equalFatIds = fat1Sector0[0] == fat2Sector0[0] && fat1Sector0[1] == fat2Sector0[1];
// Volume is software interleaved 2:1
@@ -388,17 +388,17 @@ public sealed partial class FAT
0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20
})
{
- imagePlugin.ReadSector(rootSector, out byte[] tmp);
+ imagePlugin.ReadSector(rootSector, out byte[] tmp, out _);
rootMs.Write(tmp, 0, tmp.Length);
}
byte[] rootDir = rootMs.ToArray();
- bool validRootDir = true;
+ var validRootDir = true;
// Iterate all root directory
- for(int e = 0; e < 96 * 32; e += 32)
+ for(var e = 0; e < 96 * 32; e += 32)
{
- for(int c = 0; c < 11; c++)
+ for(var c = 0; c < 11; c++)
{
if((rootDir[c + e] >= 0x20 || rootDir[c + e] == 0x00 || rootDir[c + e] == 0x05) &&
rootDir[c + e] != 0xFF &&
@@ -449,7 +449,7 @@ public sealed partial class FAT
!useExtendedBpb &&
!useApricotBpb)
{
- imagePlugin.ReadSector(1 + partition.Start, out byte[] fatSector);
+ imagePlugin.ReadSector(1 + partition.Start, out byte[] fatSector, out _);
switch(fatSector[0])
{
@@ -808,7 +808,8 @@ public sealed partial class FAT
{
imagePlugin.ReadSectors(apricotBpb.bootLocation,
(uint)(apricotBpb.sectorSize * apricotBpb.bootSize) / imagePlugin.Info.SectorSize,
- out fakeBpb.boot_code);
+ out fakeBpb.boot_code,
+ out _);
}
return BpbKind.Apricot;
diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs
index 5aaa53eb0..27e542ba1 100644
--- a/Aaru.Filesystems/FAT/Dir.cs
+++ b/Aaru.Filesystems/FAT/Dir.cs
@@ -105,7 +105,7 @@ public sealed partial class FAT
currentDirectory = _rootDirectoryCache;
- for(int p = 0; p < pieces.Length; p++)
+ for(var p = 0; p < pieces.Length; p++)
{
entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]);
@@ -139,13 +139,14 @@ public sealed partial class FAT
if(clusters is null) return ErrorNumber.InvalidArgument;
- byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length];
+ var directoryBuffer = new byte[_bytesPerCluster * clusters.Length];
- for(int i = 0; i < clusters.Length; i++)
+ for(var i = 0; i < clusters.Length; i++)
{
ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster,
_sectorsPerCluster,
- out byte[] buffer);
+ out byte[] buffer,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -156,7 +157,7 @@ public sealed partial class FAT
byte[] lastLfnName = null;
byte lastLfnChecksum = 0;
- for(int pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf())
+ for(var pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf())
{
DirectoryEntry dirent =
Marshal.ByteArrayToStructureLittleEndian(directoryBuffer,
@@ -247,7 +248,7 @@ public sealed partial class FAT
name = ":{EMPTYNAME}:";
// Try to create a unique filename with an extension from 000 to 999
- for(int uniq = 0; uniq < 1000; uniq++)
+ for(var uniq = 0; uniq < 1000; uniq++)
{
extension = $"{uniq:D03}";
@@ -318,11 +319,11 @@ public sealed partial class FAT
if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) continue;
- ushort longnameSize = BitConverter.ToUInt16(longnameEa, 2);
+ var longnameSize = BitConverter.ToUInt16(longnameEa, 2);
if(longnameSize + 4 > longnameEa.Length) continue;
- byte[] longnameBytes = new byte[longnameSize];
+ var longnameBytes = new byte[longnameSize];
Array.Copy(longnameEa, 4, longnameBytes, 0, longnameSize);
diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs
index 349ff92b2..50753b1d9 100644
--- a/Aaru.Filesystems/FAT/File.cs
+++ b/Aaru.Filesystems/FAT/File.cs
@@ -40,172 +40,6 @@ namespace Aaru.Filesystems;
public sealed partial class FAT
{
-#region IReadOnlyFilesystem Members
-
- ///
- public ErrorNumber GetAttributes(string path, out FileAttributes attributes)
- {
- attributes = new FileAttributes();
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- ErrorNumber err = Stat(path, out FileEntryInfo stat);
-
- if(err != ErrorNumber.NoError) return err;
-
- attributes = stat.Attributes;
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber OpenFile(string path, out IFileNode node)
- {
- node = null;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- ErrorNumber err = Stat(path, out FileEntryInfo stat);
-
- if(err != ErrorNumber.NoError) return err;
-
- if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) return ErrorNumber.IsDirectory;
-
- uint[] clusters = GetClusters((uint)stat.Inode);
-
- if(clusters is null) return ErrorNumber.InvalidArgument;
-
- node = new FatFileNode
- {
- Path = path,
- Length = stat.Length,
- Offset = 0,
- Clusters = clusters
- };
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber CloseFile(IFileNode node)
- {
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- if(node is not FatFileNode mynode) return ErrorNumber.InvalidArgument;
-
- mynode.Clusters = null;
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber ReadFile(IFileNode node, long length, byte[] buffer, out long read)
- {
- read = 0;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument;
-
- if(node is not FatFileNode mynode) return ErrorNumber.InvalidArgument;
-
- read = length;
-
- if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset;
-
- long firstCluster = mynode.Offset / _bytesPerCluster;
- long offsetInCluster = mynode.Offset % _bytesPerCluster;
- long sizeInClusters = (read + offsetInCluster) / _bytesPerCluster;
-
- if((read + offsetInCluster) % _bytesPerCluster > 0) sizeInClusters++;
-
- var ms = new MemoryStream();
-
- for(var i = 0; i < sizeInClusters; i++)
- {
- if(i + firstCluster >= mynode.Clusters.Length) return ErrorNumber.InvalidArgument;
-
- ErrorNumber errno =
- _image.ReadSectors(_firstClusterSector + mynode.Clusters[i + firstCluster] * _sectorsPerCluster,
- _sectorsPerCluster,
- out byte[] buf);
-
- if(errno != ErrorNumber.NoError) return errno;
-
- ms.Write(buf, 0, buf.Length);
- }
-
- ms.Position = offsetInCluster;
- ms.EnsureRead(buffer, 0, (int)read);
- mynode.Offset += read;
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber Stat(string path, out FileEntryInfo stat)
- {
- stat = null;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry completeEntry);
-
- if(err != ErrorNumber.NoError) return err;
-
- DirectoryEntry entry = completeEntry.Dirent;
-
- stat = new FileEntryInfo
- {
- Attributes = new FileAttributes(),
- Blocks = entry.size / _bytesPerCluster,
- BlockSize = _bytesPerCluster,
- Length = entry.size,
- Inode = (ulong)(_fat32 ? (entry.ea_handle << 16) + entry.start_cluster : entry.start_cluster),
- Links = 1
- };
-
- if(entry.cdate > 0 || entry.ctime > 0) stat.CreationTime = DateHandlers.DosToDateTime(entry.cdate, entry.ctime);
-
- if(_namespace != Namespace.Human)
- {
- if(entry.mdate > 0 || entry.mtime > 0)
- stat.LastWriteTime = DateHandlers.DosToDateTime(entry.mdate, entry.mtime);
-
- if(entry.ctime_ms > 0) stat.CreationTime = stat.CreationTime?.AddMilliseconds(entry.ctime_ms * 10);
- }
-
- if(entry.size % _bytesPerCluster > 0) stat.Blocks++;
-
- if(entry.attributes.HasFlag(FatAttributes.Subdirectory))
- {
- stat.Attributes |= FileAttributes.Directory;
-
- if(_fat32 && entry.ea_handle << 16 > 0 || entry.start_cluster > 0)
- {
- stat.Blocks = _fat32
- ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster))?.Length ?? 0
- : GetClusters(entry.start_cluster)?.Length ?? 0;
- }
-
- stat.Length = stat.Blocks * stat.BlockSize;
- }
-
- if(entry.attributes.HasFlag(FatAttributes.ReadOnly)) stat.Attributes |= FileAttributes.ReadOnly;
-
- if(entry.attributes.HasFlag(FatAttributes.Hidden)) stat.Attributes |= FileAttributes.Hidden;
-
- if(entry.attributes.HasFlag(FatAttributes.System)) stat.Attributes |= FileAttributes.System;
-
- if(entry.attributes.HasFlag(FatAttributes.Archive)) stat.Attributes |= FileAttributes.Archive;
-
- if(entry.attributes.HasFlag(FatAttributes.Device)) stat.Attributes |= FileAttributes.Device;
-
- return ErrorNumber.NoError;
- }
-
-#endregion
-
uint[] GetClusters(uint startCluster)
{
if(startCluster == 0) return [];
@@ -221,7 +55,7 @@ public sealed partial class FAT
var nextEntry = (int)(nextCluster % _fatEntriesPerSector);
ulong currentSector = nextSector;
- ErrorNumber errno = _image.ReadSector(currentSector, out byte[] fatData);
+ ErrorNumber errno = _image.ReadSector(currentSector, out byte[] fatData, out _);
if(errno != ErrorNumber.NoError) return null;
@@ -233,7 +67,7 @@ public sealed partial class FAT
if(currentSector != nextSector)
{
- errno = _image.ReadSector(nextSector, out fatData);
+ errno = _image.ReadSector(nextSector, out fatData, out _);
if(errno != ErrorNumber.NoError) return null;
@@ -322,4 +156,171 @@ public sealed partial class FAT
return sum;
}
+
+#region IReadOnlyFilesystem Members
+
+ ///
+ public ErrorNumber GetAttributes(string path, out FileAttributes attributes)
+ {
+ attributes = new FileAttributes();
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ ErrorNumber err = Stat(path, out FileEntryInfo stat);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ attributes = stat.Attributes;
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber OpenFile(string path, out IFileNode node)
+ {
+ node = null;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ ErrorNumber err = Stat(path, out FileEntryInfo stat);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) return ErrorNumber.IsDirectory;
+
+ uint[] clusters = GetClusters((uint)stat.Inode);
+
+ if(clusters is null) return ErrorNumber.InvalidArgument;
+
+ node = new FatFileNode
+ {
+ Path = path,
+ Length = stat.Length,
+ Offset = 0,
+ Clusters = clusters
+ };
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber CloseFile(IFileNode node)
+ {
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ if(node is not FatFileNode mynode) return ErrorNumber.InvalidArgument;
+
+ mynode.Clusters = null;
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber ReadFile(IFileNode node, long length, byte[] buffer, out long read)
+ {
+ read = 0;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument;
+
+ if(node is not FatFileNode mynode) return ErrorNumber.InvalidArgument;
+
+ read = length;
+
+ if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset;
+
+ long firstCluster = mynode.Offset / _bytesPerCluster;
+ long offsetInCluster = mynode.Offset % _bytesPerCluster;
+ long sizeInClusters = (read + offsetInCluster) / _bytesPerCluster;
+
+ if((read + offsetInCluster) % _bytesPerCluster > 0) sizeInClusters++;
+
+ var ms = new MemoryStream();
+
+ for(var i = 0; i < sizeInClusters; i++)
+ {
+ if(i + firstCluster >= mynode.Clusters.Length) return ErrorNumber.InvalidArgument;
+
+ ErrorNumber errno =
+ _image.ReadSectors(_firstClusterSector + mynode.Clusters[i + firstCluster] * _sectorsPerCluster,
+ _sectorsPerCluster,
+ out byte[] buf,
+ out _);
+
+ if(errno != ErrorNumber.NoError) return errno;
+
+ ms.Write(buf, 0, buf.Length);
+ }
+
+ ms.Position = offsetInCluster;
+ ms.EnsureRead(buffer, 0, (int)read);
+ mynode.Offset += read;
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber Stat(string path, out FileEntryInfo stat)
+ {
+ stat = null;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry completeEntry);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ DirectoryEntry entry = completeEntry.Dirent;
+
+ stat = new FileEntryInfo
+ {
+ Attributes = new FileAttributes(),
+ Blocks = entry.size / _bytesPerCluster,
+ BlockSize = _bytesPerCluster,
+ Length = entry.size,
+ Inode = (ulong)(_fat32 ? (entry.ea_handle << 16) + entry.start_cluster : entry.start_cluster),
+ Links = 1
+ };
+
+ if(entry.cdate > 0 || entry.ctime > 0) stat.CreationTime = DateHandlers.DosToDateTime(entry.cdate, entry.ctime);
+
+ if(_namespace != Namespace.Human)
+ {
+ if(entry.mdate > 0 || entry.mtime > 0)
+ stat.LastWriteTime = DateHandlers.DosToDateTime(entry.mdate, entry.mtime);
+
+ if(entry.ctime_ms > 0) stat.CreationTime = stat.CreationTime?.AddMilliseconds(entry.ctime_ms * 10);
+ }
+
+ if(entry.size % _bytesPerCluster > 0) stat.Blocks++;
+
+ if(entry.attributes.HasFlag(FatAttributes.Subdirectory))
+ {
+ stat.Attributes |= FileAttributes.Directory;
+
+ if(_fat32 && entry.ea_handle << 16 > 0 || entry.start_cluster > 0)
+ {
+ stat.Blocks = _fat32
+ ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster))?.Length ?? 0
+ : GetClusters(entry.start_cluster)?.Length ?? 0;
+ }
+
+ stat.Length = stat.Blocks * stat.BlockSize;
+ }
+
+ if(entry.attributes.HasFlag(FatAttributes.ReadOnly)) stat.Attributes |= FileAttributes.ReadOnly;
+
+ if(entry.attributes.HasFlag(FatAttributes.Hidden)) stat.Attributes |= FileAttributes.Hidden;
+
+ if(entry.attributes.HasFlag(FatAttributes.System)) stat.Attributes |= FileAttributes.System;
+
+ if(entry.attributes.HasFlag(FatAttributes.Archive)) stat.Attributes |= FileAttributes.Archive;
+
+ if(entry.attributes.HasFlag(FatAttributes.Device)) stat.Attributes |= FileAttributes.Device;
+
+ return ErrorNumber.NoError;
+ }
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs
index be65cad27..a3730349e 100644
--- a/Aaru.Filesystems/FAT/Info.cs
+++ b/Aaru.Filesystems/FAT/Info.cs
@@ -65,20 +65,20 @@ public sealed partial class FAT
byte bpbSignature;
byte fat32Signature;
ulong hugeSectors;
- byte[] fat32Id = new byte[8];
- byte[] msxId = new byte[6];
+ var fat32Id = new byte[8];
+ var msxId = new byte[6];
byte fatId;
- byte[] dosOem = new byte[8];
- byte[] atariOem = new byte[6];
+ var dosOem = new byte[8];
+ var atariOem = new byte[6];
ushort bootable = 0;
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
- ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector, out _);
if(errno != ErrorNumber.NoError) return false;
- errno = imagePlugin.ReadSector(sectorsPerBpb + partition.Start, out byte[] fatSector);
+ errno = imagePlugin.ReadSector(sectorsPerBpb + partition.Start, out byte[] fatSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -187,14 +187,14 @@ public sealed partial class FAT
AaruLogging.Debug(MODULE_NAME, "huge_sectors = {0}", hugeSectors);
AaruLogging.Debug(MODULE_NAME, "fat_id = 0x{0:X2}", fatId);
- ushort apricotBps = BitConverter.ToUInt16(bpbSector, 0x50);
- byte apricotSpc = bpbSector[0x52];
- ushort apricotReservedSecs = BitConverter.ToUInt16(bpbSector, 0x53);
- byte apricotFatsNo = bpbSector[0x55];
- ushort apricotRootEntries = BitConverter.ToUInt16(bpbSector, 0x56);
- ushort apricotSectors = BitConverter.ToUInt16(bpbSector, 0x58);
- byte apricotMediaDescriptor = bpbSector[0x5A];
- ushort apricotFatSectors = BitConverter.ToUInt16(bpbSector, 0x5B);
+ var apricotBps = BitConverter.ToUInt16(bpbSector, 0x50);
+ byte apricotSpc = bpbSector[0x52];
+ var apricotReservedSecs = BitConverter.ToUInt16(bpbSector, 0x53);
+ byte apricotFatsNo = bpbSector[0x55];
+ var apricotRootEntries = BitConverter.ToUInt16(bpbSector, 0x56);
+ var apricotSectors = BitConverter.ToUInt16(bpbSector, 0x58);
+ byte apricotMediaDescriptor = bpbSector[0x5A];
+ var apricotFatSectors = BitConverter.ToUInt16(bpbSector, 0x5B);
bool apricotCorrectSpc = apricotSpc is 1 or 2 or 4 or 8 or 16 or 32 or 64;
@@ -238,12 +238,13 @@ public sealed partial class FAT
if(16 + partition.Start <= partition.End)
{
errno = imagePlugin.ReadSector(16 + partition.Start,
- out byte[] hpfsSbSector); // Seek to superblock, on logical sector 16
+ out byte[] hpfsSbSector,
+ out _); // Seek to superblock, on logical sector 16
if(errno != ErrorNumber.NoError) return false;
- uint hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000);
- uint hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004);
+ var hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000);
+ var hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004);
if(hpfsMagic1 == 0xF995E849 && hpfsMagic2 == 0xFA53E9C5) return false;
}
@@ -317,12 +318,12 @@ public sealed partial class FAT
byte z80Di = bpbSector[0];
// First FAT1 sector resides at LBA 0x14
- errno = imagePlugin.ReadSector(0x14, out byte[] fat1Sector0);
+ errno = imagePlugin.ReadSector(0x14, out byte[] fat1Sector0, out _);
if(errno != ErrorNumber.NoError) return false;
// First FAT2 sector resides at LBA 0x1A
- errno = imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0);
+ errno = imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -336,7 +337,7 @@ public sealed partial class FAT
0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20
})
{
- errno = imagePlugin.ReadSector(rootSector, out byte[] tmp);
+ errno = imagePlugin.ReadSector(rootSector, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -344,12 +345,12 @@ public sealed partial class FAT
}
byte[] rootDir = rootMs.ToArray();
- bool validRootDir = true;
+ var validRootDir = true;
// Iterate all root directory
- for(int e = 0; e < 96 * 32; e += 32)
+ for(var e = 0; e < 96 * 32; e += 32)
{
- for(int c = 0; c < 11; c++)
+ for(var c = 0; c < 11; c++)
{
if((rootDir[c + e] >= 0x20 || rootDir[c + e] == 0x00 || rootDir[c + e] == 0x05) &&
rootDir[c + e] != 0xFF &&
@@ -372,9 +373,9 @@ public sealed partial class FAT
return true;
}
- byte fat2 = fatSector[1];
- byte fat3 = fatSector[2];
- ushort fatCluster2 = (ushort)((fat2 << 8) + fat3 & 0xFFF);
+ byte fat2 = fatSector[1];
+ byte fat3 = fatSector[2];
+ var fatCluster2 = (ushort)((fat2 << 8) + fat3 & 0xFFF);
AaruLogging.Debug(MODULE_NAME, "1st fat cluster 1 = {0:X3}", fatCluster2);
@@ -428,7 +429,7 @@ public sealed partial class FAT
AaruLogging.Debug(MODULE_NAME, Localization.Second_fat_starts_at_0, fat2SectorNo);
- errno = imagePlugin.ReadSector(fat2SectorNo, out byte[] fat2Sector);
+ errno = imagePlugin.ReadSector(fat2SectorNo, out byte[] fat2Sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -453,7 +454,7 @@ public sealed partial class FAT
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
- ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -467,9 +468,9 @@ public sealed partial class FAT
out bool andosOemCorrect,
out bool bootable);
- bool isFat12 = false;
- bool isFat16 = false;
- bool isFat32 = false;
+ var isFat12 = false;
+ var isFat16 = false;
+ var isFat32 = false;
ulong rootDirectorySector = 0;
string extraInfo = null;
string bootChk = null;
@@ -641,7 +642,9 @@ public sealed partial class FAT
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
{
- errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, out byte[] fsinfoSector);
+ errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start,
+ out byte[] fsinfoSector,
+ out _);
if(errno != ErrorNumber.NoError) return;
@@ -669,7 +672,7 @@ public sealed partial class FAT
{
ushort sum = 0;
- for(int i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i);
+ for(var i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i);
// TODO: Check this
if(sum == 0x1234)
@@ -689,7 +692,7 @@ public sealed partial class FAT
if(atariBpb.ldmode == 0)
{
- byte[] tmp = new byte[8];
+ var tmp = new byte[8];
Array.Copy(atariBpb.fname, 0, tmp, 0, 8);
string fname = Encoding.ASCII.GetString(tmp).Trim();
tmp = new byte[3];
@@ -772,19 +775,19 @@ public sealed partial class FAT
if(clusters < 4089)
{
// The first 2 FAT entries do not count as allocation clusters in FAT12 and FAT16
- ushort[] fat12 = new ushort[clusters + 2];
+ var fat12 = new ushort[clusters + 2];
_reservedSectors = fakeBpb.rsectors;
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
_fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector;
- errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes);
+ errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes, out _);
if(errno != ErrorNumber.NoError) return;
- int pos = 0;
+ var pos = 0;
- for(int i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3)
+ for(var i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3)
{
fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]);
@@ -1031,7 +1034,8 @@ public sealed partial class FAT
{
errno = imagePlugin.ReadSectors(rootDirectorySector + partition.Start,
sectorsForRootDirectory,
- out byte[] rootDirectory);
+ out byte[] rootDirectory,
+ out _);
if(errno != ErrorNumber.NoError) return;
@@ -1044,7 +1048,7 @@ public sealed partial class FAT
0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20
})
{
- errno = imagePlugin.ReadSector(rootSector, out byte[] tmp);
+ errno = imagePlugin.ReadSector(rootSector, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return;
@@ -1054,7 +1058,7 @@ public sealed partial class FAT
rootDirectory = rootMs.ToArray();
}
- for(int i = 0; i < rootDirectory.Length; i += 32)
+ for(var i = 0; i < rootDirectory.Length; i += 32)
{
// Not a correct entry
if(rootDirectory[i] < DIRENT_MIN && rootDirectory[i] != DIRENT_E5) continue;
@@ -1067,7 +1071,7 @@ public sealed partial class FAT
DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, 32);
- byte[] fullname = new byte[11];
+ var fullname = new byte[11];
Array.Copy(entry.filename, 0, fullname, 0, 8);
Array.Copy(entry.extension, 0, fullname, 8, 3);
string volname = encoding.GetString(fullname).Trim();
@@ -1112,8 +1116,8 @@ public sealed partial class FAT
// Intel short jump
case 0xEB when bpbSector[1] < 0x80:
{
- int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
- byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
+ int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
+ var bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length);
Sha1Context.Data(bootCode, out _);
@@ -1123,8 +1127,8 @@ public sealed partial class FAT
// Intel big jump
case 0xE9 when BitConverter.ToUInt16(bpbSector, 1) < 0x1FC:
{
- int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
- byte[] bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3];
+ int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
+ var bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3];
Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0, bootCode.Length);
Sha1Context.Data(bootCode, out _);
diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs
index 18b5914bc..72b92f580 100644
--- a/Aaru.Filesystems/FAT/Super.cs
+++ b/Aaru.Filesystems/FAT/Super.cs
@@ -96,7 +96,7 @@ public sealed partial class FAT
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
- ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -193,9 +193,8 @@ public sealed partial class FAT
};
if((fat32Bpb.flags & 0xF8) == 0x00)
- {
- if((fat32Bpb.flags & 0x01) == 0x01) Metadata.Dirty = true;
- }
+ if((fat32Bpb.flags & 0x01) == 0x01)
+ Metadata.Dirty = true;
if((fat32Bpb.mirror_flags & 0x80) == 0x80) _useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1;
@@ -224,7 +223,9 @@ public sealed partial class FAT
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
{
- errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, out byte[] fsinfoSector);
+ errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start,
+ out byte[] fsinfoSector,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -243,7 +244,7 @@ public sealed partial class FAT
{
ushort sum = 0;
- for(int i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i);
+ for(var i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i);
// TODO: Check this
if(sum == 0x1234) Metadata.Bootable = true;
@@ -318,19 +319,19 @@ public sealed partial class FAT
{
if(clusters < 4089)
{
- ushort[] fat12 = new ushort[clusters + 1];
+ var fat12 = new ushort[clusters + 1];
_reservedSectors = fakeBpb.rsectors;
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
_fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector;
- errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes);
+ errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes, out _);
if(errno != ErrorNumber.NoError) return errno;
- int pos = 0;
+ var pos = 0;
- for(int i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3)
+ for(var i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3)
{
fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]);
@@ -457,9 +458,8 @@ public sealed partial class FAT
if(fakeBpb.signature is 0x28 or 0x29 || andosOemCorrect)
{
if((fakeBpb.flags & 0xF8) == 0x00)
- {
- if((fakeBpb.flags & 0x01) == 0x01) Metadata.Dirty = true;
- }
+ if((fakeBpb.flags & 0x01) == 0x01)
+ Metadata.Dirty = true;
if(fakeBpb.signature == 0x29 || andosOemCorrect)
{
@@ -512,7 +512,7 @@ public sealed partial class FAT
if(!_fat32)
{
_firstClusterSector = firstRootSector + sectorsForRootDirectory - _sectorsPerCluster * 2;
- errno = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory, out rootDirectory);
+ errno = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory, out rootDirectory, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -525,7 +525,7 @@ public sealed partial class FAT
0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20
})
{
- errno = imagePlugin.ReadSector(rootSector, out byte[] tmp);
+ errno = imagePlugin.ReadSector(rootSector, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -546,7 +546,8 @@ public sealed partial class FAT
{
errno = imagePlugin.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster,
_sectorsPerCluster,
- out byte[] buffer);
+ out byte[] buffer,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -564,7 +565,7 @@ public sealed partial class FAT
byte[] lastLfnName = null;
byte lastLfnChecksum = 0;
- for(int i = 0; i < rootDirectory.Length; i += Marshal.SizeOf())
+ for(var i = 0; i < rootDirectory.Length; i += Marshal.SizeOf())
{
DirectoryEntry entry =
Marshal.ByteArrayToStructureLittleEndian(rootDirectory,
@@ -619,7 +620,7 @@ public sealed partial class FAT
if(entry.attributes.HasFlag(FatAttributes.VolumeLabel))
{
- byte[] fullname = new byte[11];
+ var fullname = new byte[11];
Array.Copy(entry.filename, 0, fullname, 0, 8);
Array.Copy(entry.extension, 0, fullname, 8, 3);
string volname = _encoding.GetString(fullname).Trim();
@@ -694,7 +695,7 @@ public sealed partial class FAT
name = ":{EMPTYNAME}:";
// Try to create a unique filename with an extension from 000 to 999
- for(int uniq = 0; uniq < 1000; uniq++)
+ for(var uniq = 0; uniq < 1000; uniq++)
{
extension = $"{uniq:D03}";
@@ -761,22 +762,22 @@ public sealed partial class FAT
_bytesPerCluster = _sectorsPerCluster * imagePlugin.Info.SectorSize;
// The first 2 FAT entries do not count as allocation clusters in FAT12 and FAT16
- ushort[] firstFatEntries = new ushort[_statfs.Blocks + 2];
- ushort[] secondFatEntries = new ushort[_statfs.Blocks + 2];
- bool firstFatValid = true;
- bool secondFatValid = true;
+ var firstFatEntries = new ushort[_statfs.Blocks + 2];
+ var secondFatEntries = new ushort[_statfs.Blocks + 2];
+ var firstFatValid = true;
+ var secondFatValid = true;
if(_fat12)
{
AaruLogging.Debug(MODULE_NAME, Localization.Reading_FAT12);
- errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes);
+ errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes, out _);
if(errno != ErrorNumber.NoError) return errno;
- int pos = 0;
+ var pos = 0;
- for(int i = 0; i + 3 < fatBytes.Length && pos < firstFatEntries.Length; i += 3)
+ for(var i = 0; i + 3 < fatBytes.Length && pos < firstFatEntries.Length; i += 3)
{
firstFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]);
@@ -785,7 +786,7 @@ public sealed partial class FAT
firstFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4));
}
- errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes);
+ errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -793,7 +794,7 @@ public sealed partial class FAT
pos = 0;
- for(int i = 0; i + 3 < fatBytes.Length && pos < secondFatEntries.Length; i += 3)
+ for(var i = 0; i + 3 < fatBytes.Length && pos < secondFatEntries.Length; i += 3)
{
secondFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]);
@@ -819,14 +820,14 @@ public sealed partial class FAT
{
AaruLogging.Debug(MODULE_NAME, Localization.Reading_FAT16);
- errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes);
+ errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes, out _);
if(errno != ErrorNumber.NoError) return errno;
AaruLogging.Debug(MODULE_NAME, Localization.Casting_FAT);
firstFatEntries = MemoryMarshal.Cast(fatBytes).ToArray();
- errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes);
+ errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -855,7 +856,7 @@ public sealed partial class FAT
if(_eaDirEntry.start_cluster != 0)
{
CacheEaData();
- ushort eamagic = BitConverter.ToUInt16(_cachedEaData, 0);
+ var eamagic = BitConverter.ToUInt16(_cachedEaData, 0);
if(eamagic != EADATA_MAGIC)
{
@@ -882,11 +883,11 @@ public sealed partial class FAT
if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) continue;
- ushort longnameSize = BitConverter.ToUInt16(longnameEa, 2);
+ var longnameSize = BitConverter.ToUInt16(longnameEa, 2);
if(longnameSize + 4 > longnameEa.Length) continue;
- byte[] longnameBytes = new byte[longnameSize];
+ var longnameBytes = new byte[longnameSize];
Array.Copy(longnameEa, 4, longnameBytes, 0, longnameSize);
diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs
index 52a8b5b34..ad72ec8e4 100644
--- a/Aaru.Filesystems/FAT/Xattr.cs
+++ b/Aaru.Filesystems/FAT/Xattr.cs
@@ -40,80 +40,6 @@ public sealed partial class FAT
{
Dictionary> _eaCache;
-#region IReadOnlyFilesystem Members
-
- ///
- public ErrorNumber ListXAttr(string path, out List xattrs)
- {
- xattrs = null;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- // No other xattr recognized yet
- if(_cachedEaData is null && !_fat32) return ErrorNumber.NotSupported;
-
- if(path[0] == '/') path = path[1..];
-
- if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas))
- {
- xattrs = eas.Keys.ToList();
-
- return ErrorNumber.NoError;
- }
-
- ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry entry);
-
- if(err != ErrorNumber.NoError || entry is null) return err;
-
- xattrs = [];
-
- if(!_fat32)
- {
- if(entry.Dirent.ea_handle == 0) return ErrorNumber.NoError;
-
- eas = GetEas(entry.Dirent.ea_handle);
- }
- else
- {
- if(entry.Fat32Ea.start_cluster == 0) return ErrorNumber.NoError;
-
- eas = GetEas(entry.Fat32Ea);
- }
-
- if(eas is null) return ErrorNumber.NoError;
-
- _eaCache.Add(path.ToLower(_cultureInfo), eas);
- xattrs = eas.Keys.ToList();
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf)
- {
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- ErrorNumber err = ListXAttr(path, out List xattrs);
-
- if(err != ErrorNumber.NoError) return err;
-
- if(path[0] == '/') path = path[1..];
-
- if(!xattrs.Contains(xattr.ToLower(_cultureInfo))) return ErrorNumber.NoSuchExtendedAttribute;
-
- if(!_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas))
- return ErrorNumber.InvalidArgument;
-
- if(!eas.TryGetValue(xattr.ToLower(_cultureInfo), out byte[] data)) return ErrorNumber.InvalidArgument;
-
- buf = new byte[data.Length];
- data.CopyTo(buf, 0);
-
- return ErrorNumber.NoError;
- }
-
-#endregion
-
Dictionary GetEas(DirectoryEntry entryFat32Ea)
{
var eaMs = new MemoryStream();
@@ -123,7 +49,8 @@ public sealed partial class FAT
{
ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster,
_sectorsPerCluster,
- out byte[] buffer);
+ out byte[] buffer,
+ out _);
if(errno != ErrorNumber.NoError) return null;
@@ -221,7 +148,8 @@ public sealed partial class FAT
{
ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster,
_sectorsPerCluster,
- out byte[] buffer);
+ out byte[] buffer,
+ out _);
if(errno != ErrorNumber.NoError) break;
@@ -230,4 +158,78 @@ public sealed partial class FAT
_cachedEaData = eaDataMs.ToArray();
}
+
+#region IReadOnlyFilesystem Members
+
+ ///
+ public ErrorNumber ListXAttr(string path, out List xattrs)
+ {
+ xattrs = null;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ // No other xattr recognized yet
+ if(_cachedEaData is null && !_fat32) return ErrorNumber.NotSupported;
+
+ if(path[0] == '/') path = path[1..];
+
+ if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas))
+ {
+ xattrs = eas.Keys.ToList();
+
+ return ErrorNumber.NoError;
+ }
+
+ ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry entry);
+
+ if(err != ErrorNumber.NoError || entry is null) return err;
+
+ xattrs = [];
+
+ if(!_fat32)
+ {
+ if(entry.Dirent.ea_handle == 0) return ErrorNumber.NoError;
+
+ eas = GetEas(entry.Dirent.ea_handle);
+ }
+ else
+ {
+ if(entry.Fat32Ea.start_cluster == 0) return ErrorNumber.NoError;
+
+ eas = GetEas(entry.Fat32Ea);
+ }
+
+ if(eas is null) return ErrorNumber.NoError;
+
+ _eaCache.Add(path.ToLower(_cultureInfo), eas);
+ xattrs = eas.Keys.ToList();
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf)
+ {
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ ErrorNumber err = ListXAttr(path, out List xattrs);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ if(path[0] == '/') path = path[1..];
+
+ if(!xattrs.Contains(xattr.ToLower(_cultureInfo))) return ErrorNumber.NoSuchExtendedAttribute;
+
+ if(!_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas))
+ return ErrorNumber.InvalidArgument;
+
+ if(!eas.TryGetValue(xattr.ToLower(_cultureInfo), out byte[] data)) return ErrorNumber.InvalidArgument;
+
+ buf = new byte[data.Length];
+ data.CopyTo(buf, 0);
+
+ return ErrorNumber.NoError;
+ }
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs
index 890ac1d0c..057413b47 100644
--- a/Aaru.Filesystems/FATX/Dir.cs
+++ b/Aaru.Filesystems/FATX/Dir.cs
@@ -113,7 +113,8 @@ public sealed partial class XboxFatPlugin
ErrorNumber errno =
_imagePlugin.ReadSectors(_firstClusterSector + (clusters[i] - 1) * _sectorsPerCluster,
_sectorsPerCluster,
- out byte[] buffer);
+ out byte[] buffer,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs
index 8d0cb9c36..1283298f0 100644
--- a/Aaru.Filesystems/FATX/File.cs
+++ b/Aaru.Filesystems/FATX/File.cs
@@ -40,6 +40,78 @@ namespace Aaru.Filesystems;
public sealed partial class XboxFatPlugin
{
+ uint[] GetClusters(uint startCluster)
+ {
+ if(startCluster == 0) return null;
+
+ if(_fat16 is null)
+ {
+ if(startCluster >= _fat32.Length) return null;
+ }
+ else if(startCluster >= _fat16.Length) return null;
+
+ List clusters = [];
+
+ uint nextCluster = startCluster;
+
+ if(_fat16 is null)
+ {
+ while((nextCluster & FAT32_MASK) > 0 && (nextCluster & FAT32_MASK) <= FAT32_RESERVED)
+ {
+ clusters.Add(nextCluster);
+ nextCluster = _fat32[nextCluster];
+ }
+ }
+ else
+ {
+ while(nextCluster is > 0 and <= FAT16_RESERVED)
+ {
+ clusters.Add(nextCluster);
+ nextCluster = _fat16[nextCluster];
+ }
+ }
+
+ return clusters.ToArray();
+ }
+
+ ErrorNumber GetFileEntry(string path, out DirectoryEntry entry)
+ {
+ entry = new DirectoryEntry();
+
+ string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
+
+ string[] pieces = cutPath.Split(new[]
+ {
+ '/'
+ },
+ StringSplitOptions.RemoveEmptyEntries);
+
+ if(pieces.Length == 0) return ErrorNumber.InvalidArgument;
+
+ var parentPath = string.Join("/", pieces, 0, pieces.Length - 1);
+
+ ErrorNumber err = OpenDir(parentPath, out IDirNode node);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ CloseDir(node);
+
+ Dictionary parent;
+
+ if(pieces.Length == 1)
+ parent = _rootDirectory;
+ else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument;
+
+ KeyValuePair dirent =
+ parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]);
+
+ if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile;
+
+ entry = dirent.Value;
+
+ return ErrorNumber.NoError;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -127,7 +199,8 @@ public sealed partial class XboxFatPlugin
_imagePlugin.ReadSectors(_firstClusterSector +
(mynode.Clusters[i + firstCluster] - 1) * _sectorsPerCluster,
_sectorsPerCluster,
- out byte[] buf);
+ out byte[] buf,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -209,76 +282,4 @@ public sealed partial class XboxFatPlugin
}
#endregion
-
- uint[] GetClusters(uint startCluster)
- {
- if(startCluster == 0) return null;
-
- if(_fat16 is null)
- {
- if(startCluster >= _fat32.Length) return null;
- }
- else if(startCluster >= _fat16.Length) return null;
-
- List clusters = [];
-
- uint nextCluster = startCluster;
-
- if(_fat16 is null)
- {
- while((nextCluster & FAT32_MASK) > 0 && (nextCluster & FAT32_MASK) <= FAT32_RESERVED)
- {
- clusters.Add(nextCluster);
- nextCluster = _fat32[nextCluster];
- }
- }
- else
- {
- while(nextCluster is > 0 and <= FAT16_RESERVED)
- {
- clusters.Add(nextCluster);
- nextCluster = _fat16[nextCluster];
- }
- }
-
- return clusters.ToArray();
- }
-
- ErrorNumber GetFileEntry(string path, out DirectoryEntry entry)
- {
- entry = new DirectoryEntry();
-
- string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
-
- string[] pieces = cutPath.Split(new[]
- {
- '/'
- },
- StringSplitOptions.RemoveEmptyEntries);
-
- if(pieces.Length == 0) return ErrorNumber.InvalidArgument;
-
- var parentPath = string.Join("/", pieces, 0, pieces.Length - 1);
-
- ErrorNumber err = OpenDir(parentPath, out IDirNode node);
-
- if(err != ErrorNumber.NoError) return err;
-
- CloseDir(node);
-
- Dictionary parent;
-
- if(pieces.Length == 1)
- parent = _rootDirectory;
- else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument;
-
- KeyValuePair dirent =
- parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]);
-
- if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile;
-
- entry = dirent.Value;
-
- return ErrorNumber.NoError;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs
index b44c1c82e..7c4af1058 100644
--- a/Aaru.Filesystems/FATX/Info.cs
+++ b/Aaru.Filesystems/FATX/Info.cs
@@ -44,7 +44,7 @@ public sealed partial class XboxFatPlugin
{
if(imagePlugin.Info.SectorSize < 512) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -64,7 +64,7 @@ public sealed partial class XboxFatPlugin
var bigEndian = true;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs
index a20558b3a..7277646ce 100644
--- a/Aaru.Filesystems/FATX/Super.cs
+++ b/Aaru.Filesystems/FATX/Super.cs
@@ -61,7 +61,7 @@ public sealed partial class XboxFatPlugin
AaruLogging.Debug(MODULE_NAME, Localization.Reading_superblock);
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -76,15 +76,13 @@ public sealed partial class XboxFatPlugin
if(_superblock.magic != FATX_MAGIC) return ErrorNumber.InvalidArgument;
AaruLogging.Debug(MODULE_NAME,
- _littleEndian
- ? Localization.Filesystem_is_little_endian
- : Localization.Filesystem_is_big_endian);
+ _littleEndian
+ ? Localization.Filesystem_is_little_endian
+ : Localization.Filesystem_is_big_endian);
int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && _littleEndian ? 8 : 1;
- AaruLogging.Debug(MODULE_NAME,
- "logicalSectorsPerPhysicalSectors = {0}",
- logicalSectorsPerPhysicalSectors);
+ AaruLogging.Debug(MODULE_NAME, "logicalSectorsPerPhysicalSectors = {0}", logicalSectorsPerPhysicalSectors);
string volumeLabel = StringHandlers.CToString(_superblock.volumeLabel,
!_littleEndian ? Encoding.BigEndianUnicode : Encoding.Unicode,
@@ -148,7 +146,7 @@ public sealed partial class XboxFatPlugin
AaruLogging.Debug(MODULE_NAME, Localization.FAT_is_0_sectors, fatSize);
- errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer);
+ errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -156,8 +154,9 @@ public sealed partial class XboxFatPlugin
_fat32 = MemoryMarshal.Cast(buffer).ToArray();
if(!_littleEndian)
- for(int i = 0; i < _fat32.Length; i++)
- _fat32[i] = Swapping.Swap(_fat32[i]);
+ {
+ for(var i = 0; i < _fat32.Length; i++) _fat32[i] = Swapping.Swap(_fat32[i]);
+ }
AaruLogging.Debug(MODULE_NAME, "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID);
@@ -179,7 +178,7 @@ public sealed partial class XboxFatPlugin
AaruLogging.Debug(MODULE_NAME, Localization.FAT_is_0_sectors, fatSize);
- errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer);
+ errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -187,8 +186,9 @@ public sealed partial class XboxFatPlugin
_fat16 = MemoryMarshal.Cast(buffer).ToArray();
if(!_littleEndian)
- for(int i = 0; i < _fat16.Length; i++)
- _fat16[i] = Swapping.Swap(_fat16[i]);
+ {
+ for(var i = 0; i < _fat16.Length; i++) _fat16[i] = Swapping.Swap(_fat16[i]);
+ }
AaruLogging.Debug(MODULE_NAME, "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID);
@@ -208,15 +208,16 @@ public sealed partial class XboxFatPlugin
if(rootDirectoryClusters is null) return ErrorNumber.InvalidArgument;
- byte[] rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length];
+ var rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length];
AaruLogging.Debug(MODULE_NAME, Localization.Reading_root_directory);
- for(int i = 0; i < rootDirectoryClusters.Length; i++)
+ for(var i = 0; i < rootDirectoryClusters.Length; i++)
{
errno = imagePlugin.ReadSectors(_firstClusterSector + (rootDirectoryClusters[i] - 1) * _sectorsPerCluster,
_sectorsPerCluster,
- out buffer);
+ out buffer,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -225,7 +226,7 @@ public sealed partial class XboxFatPlugin
_rootDirectory = new Dictionary();
- int pos = 0;
+ var pos = 0;
while(pos < rootDirectoryBuffer.Length)
{
diff --git a/Aaru.Filesystems/FFS/Info.cs b/Aaru.Filesystems/FFS/Info.cs
index a2ba068cb..40e6a458b 100644
--- a/Aaru.Filesystems/FFS/Info.cs
+++ b/Aaru.Filesystems/FFS/Info.cs
@@ -72,7 +72,7 @@ public sealed partial class FFSPlugin
foreach(ulong loc in locations.Where(loc => partition.End > partition.Start + loc + sbSizeInSectors))
{
ErrorNumber errno =
- imagePlugin.ReadSectors(partition.Start + loc, sbSizeInSectors, out byte[] ufsSbSectors);
+ imagePlugin.ReadSectors(partition.Start + loc, sbSizeInSectors, out byte[] ufsSbSectors, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -135,7 +135,7 @@ public sealed partial class FFSPlugin
foreach(ulong loc in locations.Where(loc => partition.End > partition.Start + loc + sb_size_in_sectors))
{
- errno = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors, out ufs_sb_sectors);
+ errno = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors, out ufs_sb_sectors, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -214,7 +214,7 @@ public sealed partial class FFSPlugin
}
// Fun with seeking follows on superblock reading!
- errno = imagePlugin.ReadSectors(sb_offset, sb_size_in_sectors, out ufs_sb_sectors);
+ errno = imagePlugin.ReadSectors(sb_offset, sb_size_in_sectors, out ufs_sb_sectors, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/Fossil/Info.cs b/Aaru.Filesystems/Fossil/Info.cs
index aa3c4f9c8..49772dfd1 100644
--- a/Aaru.Filesystems/Fossil/Info.cs
+++ b/Aaru.Filesystems/Fossil/Info.cs
@@ -49,7 +49,7 @@ public sealed partial class Fossil
if(partition.Start + hdrSector > imagePlugin.Info.Sectors) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -73,7 +73,7 @@ public sealed partial class Fossil
ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -102,7 +102,7 @@ public sealed partial class Fossil
if(sbLocation <= partition.End)
{
- imagePlugin.ReadSector(sbLocation, out sector);
+ imagePlugin.ReadSector(sbLocation, out sector, out _);
SuperBlock fsb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME, Localization.magic_0_expected_1, fsb.magic, FOSSIL_SB_MAGIC);
diff --git a/Aaru.Filesystems/HAMMER/Info.cs b/Aaru.Filesystems/HAMMER/Info.cs
index 70e7ff1b7..2f9501464 100644
--- a/Aaru.Filesystems/HAMMER/Info.cs
+++ b/Aaru.Filesystems/HAMMER/Info.cs
@@ -53,7 +53,7 @@ public sealed partial class HAMMER
if(run + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -76,7 +76,7 @@ public sealed partial class HAMMER
if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) run++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/HPFS/Info.cs b/Aaru.Filesystems/HPFS/Info.cs
index 524767318..d34694a90 100644
--- a/Aaru.Filesystems/HPFS/Info.cs
+++ b/Aaru.Filesystems/HPFS/Info.cs
@@ -55,7 +55,8 @@ public sealed partial class HPFS
ErrorNumber errno =
imagePlugin.ReadSector(16 + partition.Start,
- out byte[] hpfsSbSector); // Seek to superblock, on logical sector 16
+ out byte[] hpfsSbSector,
+ out _); // Seek to superblock, on logical sector 16
if(errno != ErrorNumber.NoError) return false;
@@ -77,17 +78,20 @@ public sealed partial class HPFS
ErrorNumber errno =
imagePlugin.ReadSector(0 + partition.Start,
- out byte[] hpfsBpbSector); // Seek to BIOS parameter block, on logical sector 0
+ out byte[] hpfsBpbSector,
+ out _); // Seek to BIOS parameter block, on logical sector 0
if(errno != ErrorNumber.NoError) return;
errno = imagePlugin.ReadSector(16 + partition.Start,
- out byte[] hpfsSbSector); // Seek to superblock, on logical sector 16
+ out byte[] hpfsSbSector,
+ out _); // Seek to superblock, on logical sector 16
if(errno != ErrorNumber.NoError) return;
errno = imagePlugin.ReadSector(17 + partition.Start,
- out byte[] hpfsSpSector); // Seek to spareblock, on logical sector 17
+ out byte[] hpfsSpSector,
+ out _); // Seek to spareblock, on logical sector 17
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs
index 3168ba90e..c4d54c613 100644
--- a/Aaru.Filesystems/HPOFS/Info.cs
+++ b/Aaru.Filesystems/HPOFS/Info.cs
@@ -53,7 +53,8 @@ public sealed partial class HPOFS
ErrorNumber errno =
imagePlugin.ReadSector(0 + partition.Start,
- out byte[] hpofsBpbSector); // Seek to BIOS parameter block, on logical sector 0
+ out byte[] hpofsBpbSector,
+ out _); // Seek to BIOS parameter block, on logical sector 0
if(errno != ErrorNumber.NoError) return false;
@@ -76,27 +77,28 @@ public sealed partial class HPOFS
ErrorNumber errno =
imagePlugin.ReadSector(0 + partition.Start,
- out byte[] hpofsBpbSector); // Seek to BIOS parameter block, on logical sector 0
+ out byte[] hpofsBpbSector,
+ out _); // Seek to BIOS parameter block, on logical sector 0
if(errno != ErrorNumber.NoError) return;
errno = imagePlugin.ReadSector(13 + partition.Start,
- out byte[] medInfoSector); // Seek to media information block, on logical sector 13
+ out byte[] medInfoSector,
+ out _); // Seek to media information block, on logical sector 13
if(errno != ErrorNumber.NoError) return;
errno = imagePlugin.ReadSector(14 + partition.Start,
- out byte[] volInfoSector); // Seek to volume information block, on logical sector 14
+ out byte[] volInfoSector,
+ out _); // Seek to volume information block, on logical sector 14
if(errno != ErrorNumber.NoError) return;
BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpofsBpbSector);
- MediaInformationBlock mib =
- Marshal.ByteArrayToStructureBigEndian(medInfoSector);
+ MediaInformationBlock mib = Marshal.ByteArrayToStructureBigEndian(medInfoSector);
- VolumeInformationBlock vib =
- Marshal.ByteArrayToStructureBigEndian(volInfoSector);
+ VolumeInformationBlock vib = Marshal.ByteArrayToStructureBigEndian(volInfoSector);
AaruLogging.Debug(MODULE_NAME, "bpb.oem_name = \"{0}\"", StringHandlers.CToString(bpb.oem_name));
diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs
index f363ff7b8..40c4c8a33 100644
--- a/Aaru.Filesystems/ISO9660/File.cs
+++ b/Aaru.Filesystems/ISO9660/File.cs
@@ -44,6 +44,178 @@ namespace Aaru.Filesystems;
public sealed partial class ISO9660
{
+ ErrorNumber GetFileEntry(string path, out DecodedDirectoryEntry entry)
+ {
+ entry = null;
+
+ string cutPath = path.StartsWith("/", StringComparison.Ordinal)
+ ? path[1..].ToLower(CultureInfo.CurrentUICulture)
+ : path.ToLower(CultureInfo.CurrentUICulture);
+
+ string[] pieces = cutPath.Split(new[]
+ {
+ '/'
+ },
+ StringSplitOptions.RemoveEmptyEntries);
+
+ if(pieces.Length == 0) return ErrorNumber.InvalidArgument;
+
+ var parentPath = string.Join("/", pieces, 0, pieces.Length - 1);
+
+ if(!_directoryCache.TryGetValue(parentPath, out _))
+ {
+ ErrorNumber err = OpenDir(parentPath, out IDirNode node);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ CloseDir(node);
+ }
+
+ Dictionary parent;
+
+ if(pieces.Length == 1)
+ parent = _rootDirectoryCache;
+ else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument;
+
+ KeyValuePair dirent =
+ parent.FirstOrDefault(t => t.Key.Equals(pieces[^1], StringComparison.CurrentCultureIgnoreCase));
+
+ if(string.IsNullOrEmpty(dirent.Key))
+ {
+ if(!_joliet && !pieces[^1].EndsWith(";1", StringComparison.Ordinal))
+ {
+ dirent = parent.FirstOrDefault(t => t.Key.Equals(pieces[^1] + ";1",
+ StringComparison.CurrentCultureIgnoreCase));
+
+ if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile;
+ }
+ else
+ return ErrorNumber.NoSuchFile;
+ }
+
+ entry = dirent.Value;
+
+ return ErrorNumber.NoError;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ ErrorNumber ReadSingleExtent(long size, uint startingSector, out byte[] buffer, bool interleaved = false,
+ byte fileNumber = 0) => ReadWithExtents(0,
+ size,
+ [(startingSector, (uint)size)],
+ interleaved,
+ fileNumber,
+ out buffer);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ ErrorNumber ReadSingleExtent(long offset, long size, uint startingSector, out byte[] buffer,
+ bool interleaved = false, byte fileNumber = 0) => ReadWithExtents(offset,
+ size,
+ [(startingSector, (uint)size)],
+ interleaved,
+ fileNumber,
+ out buffer);
+
+ // Cannot think how to make this faster, as we don't know the mode sector until it is read, but we have size in bytes
+ ErrorNumber ReadWithExtents(long offset, long size, List<(uint extent, uint size)> extents, bool interleaved,
+ byte fileNumber, out byte[] buffer)
+ {
+ var ms = new MemoryStream();
+ long currentFilePos = offset;
+
+ for(var i = 0; i < extents.Count; i++)
+ {
+ if(offset - currentFilePos >= extents[i].size)
+ {
+ currentFilePos += extents[i].size;
+
+ continue;
+ }
+
+ var currentExtentSector = (uint)(offset / 2048);
+ long leftExtentSize = extents[i].size - currentFilePos;
+
+ while(leftExtentSize > 0)
+ {
+ ErrorNumber errno = ReadSector(extents[i].extent + currentExtentSector,
+ out byte[] sector,
+ interleaved,
+ fileNumber);
+
+ if(errno != ErrorNumber.NoError)
+ {
+ buffer = ms.ToArray();
+
+ return errno;
+ }
+
+ if(sector is null)
+ {
+ currentExtentSector++;
+ leftExtentSize -= 2048;
+ currentFilePos += 2048;
+
+ continue;
+ }
+
+ if(offset - currentFilePos > sector.Length)
+ {
+ currentExtentSector++;
+ leftExtentSize -= sector.Length;
+ currentFilePos += sector.Length;
+
+ continue;
+ }
+
+ if(offset - currentFilePos > 0)
+ ms.Write(sector, (int)(offset - currentFilePos), (int)(sector.Length - (offset - currentFilePos)));
+ else
+ ms.Write(sector, 0, sector.Length);
+
+ currentExtentSector++;
+ leftExtentSize -= sector.Length;
+ currentFilePos += sector.Length;
+
+ if(ms.Length >= size) break;
+ }
+
+ if(ms.Length >= size) break;
+ }
+
+ if(ms.Length >= size) ms.SetLength(size);
+
+ buffer = ms.ToArray();
+
+ return ErrorNumber.NoError;
+ }
+
+ byte[] ReadSubheaderWithExtents(List<(uint extent, uint size)> extents, bool copy)
+ {
+ var ms = new MemoryStream();
+
+ for(var i = 0; i < extents.Count; i++)
+ {
+ long leftExtentSize = extents[i].size;
+ uint currentExtentSector = 0;
+
+ while(leftExtentSize > 0)
+ {
+ ErrorNumber errno = _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048,
+ SectorTagType.CdSectorSubHeader,
+ out byte[] fullSector);
+
+ if(errno != ErrorNumber.NoError) return null;
+
+ ms.Write(fullSector, copy ? 0 : 4, 4);
+
+ currentExtentSector++;
+ leftExtentSize -= 2048;
+ }
+ }
+
+ return ms.ToArray();
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -153,7 +325,8 @@ public sealed partial class ISO9660
ErrorNumber errno = _image.ReadSectorsLong((ulong)(mynode.Dentry.Extents[0].extent + firstSector),
(uint)sizeInSectors,
- out byte[] buf);
+ out byte[] buf,
+ out _);
if(errno != ErrorNumber.NoError)
{
@@ -407,176 +580,4 @@ public sealed partial class ISO9660
}
#endregion
-
- ErrorNumber GetFileEntry(string path, out DecodedDirectoryEntry entry)
- {
- entry = null;
-
- string cutPath = path.StartsWith("/", StringComparison.Ordinal)
- ? path[1..].ToLower(CultureInfo.CurrentUICulture)
- : path.ToLower(CultureInfo.CurrentUICulture);
-
- string[] pieces = cutPath.Split(new[]
- {
- '/'
- },
- StringSplitOptions.RemoveEmptyEntries);
-
- if(pieces.Length == 0) return ErrorNumber.InvalidArgument;
-
- string parentPath = string.Join("/", pieces, 0, pieces.Length - 1);
-
- if(!_directoryCache.TryGetValue(parentPath, out _))
- {
- ErrorNumber err = OpenDir(parentPath, out IDirNode node);
-
- if(err != ErrorNumber.NoError) return err;
-
- CloseDir(node);
- }
-
- Dictionary parent;
-
- if(pieces.Length == 1)
- parent = _rootDirectoryCache;
- else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument;
-
- KeyValuePair dirent =
- parent.FirstOrDefault(t => t.Key.Equals(pieces[^1], StringComparison.CurrentCultureIgnoreCase));
-
- if(string.IsNullOrEmpty(dirent.Key))
- {
- if(!_joliet && !pieces[^1].EndsWith(";1", StringComparison.Ordinal))
- {
- dirent = parent.FirstOrDefault(t => t.Key.Equals(pieces[^1] + ";1",
- StringComparison.CurrentCultureIgnoreCase));
-
- if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile;
- }
- else
- return ErrorNumber.NoSuchFile;
- }
-
- entry = dirent.Value;
-
- return ErrorNumber.NoError;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- ErrorNumber ReadSingleExtent(long size, uint startingSector, out byte[] buffer, bool interleaved = false,
- byte fileNumber = 0) => ReadWithExtents(0,
- size,
- [(startingSector, (uint)size)],
- interleaved,
- fileNumber,
- out buffer);
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- ErrorNumber ReadSingleExtent(long offset, long size, uint startingSector, out byte[] buffer,
- bool interleaved = false, byte fileNumber = 0) => ReadWithExtents(offset,
- size,
- [(startingSector, (uint)size)],
- interleaved,
- fileNumber,
- out buffer);
-
- // Cannot think how to make this faster, as we don't know the mode sector until it is read, but we have size in bytes
- ErrorNumber ReadWithExtents(long offset, long size, List<(uint extent, uint size)> extents, bool interleaved,
- byte fileNumber, out byte[] buffer)
- {
- var ms = new MemoryStream();
- long currentFilePos = offset;
-
- for(int i = 0; i < extents.Count; i++)
- {
- if(offset - currentFilePos >= extents[i].size)
- {
- currentFilePos += extents[i].size;
-
- continue;
- }
-
- uint currentExtentSector = (uint)(offset / 2048);
- long leftExtentSize = extents[i].size - currentFilePos;
-
- while(leftExtentSize > 0)
- {
- ErrorNumber errno = ReadSector(extents[i].extent + currentExtentSector,
- out byte[] sector,
- interleaved,
- fileNumber);
-
- if(errno != ErrorNumber.NoError)
- {
- buffer = ms.ToArray();
-
- return errno;
- }
-
- if(sector is null)
- {
- currentExtentSector++;
- leftExtentSize -= 2048;
- currentFilePos += 2048;
-
- continue;
- }
-
- if(offset - currentFilePos > sector.Length)
- {
- currentExtentSector++;
- leftExtentSize -= sector.Length;
- currentFilePos += sector.Length;
-
- continue;
- }
-
- if(offset - currentFilePos > 0)
- ms.Write(sector, (int)(offset - currentFilePos), (int)(sector.Length - (offset - currentFilePos)));
- else
- ms.Write(sector, 0, sector.Length);
-
- currentExtentSector++;
- leftExtentSize -= sector.Length;
- currentFilePos += sector.Length;
-
- if(ms.Length >= size) break;
- }
-
- if(ms.Length >= size) break;
- }
-
- if(ms.Length >= size) ms.SetLength(size);
-
- buffer = ms.ToArray();
-
- return ErrorNumber.NoError;
- }
-
- byte[] ReadSubheaderWithExtents(List<(uint extent, uint size)> extents, bool copy)
- {
- var ms = new MemoryStream();
-
- for(int i = 0; i < extents.Count; i++)
- {
- long leftExtentSize = extents[i].size;
- uint currentExtentSector = 0;
-
- while(leftExtentSize > 0)
- {
- ErrorNumber errno = _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048,
- SectorTagType.CdSectorSubHeader,
- out byte[] fullSector);
-
- if(errno != ErrorNumber.NoError) return null;
-
- ms.Write(fullSector, copy ? 0 : 4, 4);
-
- currentExtentSector++;
- leftExtentSize -= 2048;
- }
- }
-
- return ms.ToArray();
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs
index 7847824e8..6c089b32f 100644
--- a/Aaru.Filesystems/ISO9660/Info.cs
+++ b/Aaru.Filesystems/ISO9660/Info.cs
@@ -55,7 +55,7 @@ public sealed partial class ISO9660
if(partition.End <= 16 + partition.Start) return false;
// Read to Volume Descriptor
- ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector);
+ ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -109,7 +109,7 @@ public sealed partial class ISO9660
ulong counter = 0;
- ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector);
+ ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -130,7 +130,7 @@ public sealed partial class ISO9660
// Seek to Volume Descriptor
AaruLogging.Debug(MODULE_NAME, Localization.Reading_sector_0, 16 + counter + partition.Start);
- errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp);
+ errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp, out _);
if(errno != ErrorNumber.NoError) return;
@@ -290,7 +290,7 @@ public sealed partial class ISO9660
if(rootLocation + rootSize < imagePlugin.Info.Sectors)
{
- errno = imagePlugin.ReadSectors(rootLocation, rootSize, out rootDir);
+ errno = imagePlugin.ReadSectors(rootLocation, rootSize, out rootDir, out _);
if(errno != ErrorNumber.NoError) return;
}
@@ -454,7 +454,7 @@ public sealed partial class ISO9660
0)
caLen++;
- errno = imagePlugin.ReadSectors(ca.block_be, caLen, out byte[] caSectors);
+ errno = imagePlugin.ReadSectors(ca.block_be, caLen, out byte[] caSectors, out _);
if(errno != ErrorNumber.NoError) return;
@@ -531,7 +531,7 @@ public sealed partial class ISO9660
}
}
- errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ipbinSector);
+ errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ipbinSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -680,7 +680,7 @@ public sealed partial class ISO9660
if(torito != null)
{
- errno = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start, out vdSector);
+ errno = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start, out vdSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -714,7 +714,8 @@ public sealed partial class ISO9660
{
imagePlugin.ReadSectors(initialEntry.load_rba + partition.Start,
initialEntry.sector_count,
- out bootImage);
+ out bootImage,
+ out _);
}
isoMetadata.AppendLine(Localization.EL_TORITO_INFORMATION_border);
@@ -827,7 +828,8 @@ public sealed partial class ISO9660
{
imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start,
sectionEntry.sector_count,
- out bootImage);
+ out bootImage,
+ out _);
}
isoMetadata.AppendFormat("\t\t" + Localization.Bootable_on_0, sectionHeader.platform_id)
diff --git a/Aaru.Filesystems/ISO9660/Mode2.cs b/Aaru.Filesystems/ISO9660/Mode2.cs
index 99a4291d7..e172afd07 100644
--- a/Aaru.Filesystems/ISO9660/Mode2.cs
+++ b/Aaru.Filesystems/ISO9660/Mode2.cs
@@ -58,9 +58,9 @@ public sealed partial class ISO9660
if(sectorCount == 1)
{
- errno = _image.ReadSectorLong(realSector, out data);
+ errno = _image.ReadSectorLong(realSector, out data, out _);
- if(errno != ErrorNumber.NoError) errno = _image.ReadSector(realSector, out data);
+ if(errno != ErrorNumber.NoError) errno = _image.ReadSector(realSector, out data, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -70,26 +70,24 @@ public sealed partial class ISO9660
{
case 2048:
AaruLogging.Debug(MODULE_NAME,
- Localization.tor_Sector_0_Cooked_Mode_zero_one_Mode_two_Form_one,
- realSector);
+ Localization.tor_Sector_0_Cooked_Mode_zero_one_Mode_two_Form_one,
+ realSector);
break;
case 2324:
- AaruLogging.Debug(MODULE_NAME,
- Localization.tor_Sector_0_Cooked_Mode_two_Form_two,
- realSector);
+ AaruLogging.Debug(MODULE_NAME, Localization.tor_Sector_0_Cooked_Mode_two_Form_two, realSector);
break;
case 2336:
AaruLogging.Debug(MODULE_NAME,
- Localization
- .tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5,
- realSector,
- ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
- data[0],
- data[1],
- (Mode2Submode)data[2],
- data[3]);
+ Localization
+ .tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5,
+ realSector,
+ ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
+ data[0],
+ data[1],
+ (Mode2Submode)data[2],
+ data[3]);
break;
case 2352 when data[0] != 0x00 ||
@@ -109,27 +107,27 @@ public sealed partial class ISO9660
break;
case 2352 when data[15] != 2:
AaruLogging.Debug(MODULE_NAME,
- Localization.tor_Sector_0_1_2_3_Raw_Mode_4,
- realSector,
- data[12],
- data[13],
- data[14],
- data[15]);
+ Localization.tor_Sector_0_1_2_3_Raw_Mode_4,
+ realSector,
+ data[12],
+ data[13],
+ data[14],
+ data[15]);
break;
case 2352:
AaruLogging.Debug(MODULE_NAME,
- Localization
- .tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8,
- realSector,
- data[12],
- data[13],
- data[14],
- ((Mode2Submode)data[18]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
- data[16],
- data[17],
- (Mode2Submode)data[18],
- data[19]);
+ Localization
+ .tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8,
+ realSector,
+ data[12],
+ data[13],
+ data[14],
+ ((Mode2Submode)data[18]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
+ data[16],
+ data[17],
+ (Mode2Submode)data[18],
+ data[19]);
break;
}
@@ -142,7 +140,7 @@ public sealed partial class ISO9660
return ErrorNumber.NoError;
}
- byte[] tmp = new byte[_blockSize];
+ var tmp = new byte[_blockSize];
Array.Copy(Sector.GetUserData(data, interleaved, fileNumber), (int)offset, tmp, 0, _blockSize);
buffer = tmp;
@@ -157,9 +155,9 @@ public sealed partial class ISO9660
{
ulong dstSector = realSector + 1;
- errno = _image.ReadSectorLong(dstSector, out data);
+ errno = _image.ReadSectorLong(dstSector, out data, out _);
- if(errno != ErrorNumber.NoError) errno = _image.ReadSector(dstSector, out data);
+ if(errno != ErrorNumber.NoError) errno = _image.ReadSector(dstSector, out data, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -169,26 +167,26 @@ public sealed partial class ISO9660
{
case 2048:
AaruLogging.Debug(MODULE_NAME,
- Localization.tor_Sector_0_Cooked_Mode_zero_one_Mode_two_Form_one,
- dstSector);
+ Localization.tor_Sector_0_Cooked_Mode_zero_one_Mode_two_Form_one,
+ dstSector);
break;
case 2324:
AaruLogging.Debug(MODULE_NAME,
- Localization.tor_Sector_0_Cooked_Mode_two_Form_two,
- dstSector);
+ Localization.tor_Sector_0_Cooked_Mode_two_Form_two,
+ dstSector);
break;
case 2336:
AaruLogging.Debug(MODULE_NAME,
- Localization
- .tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5,
- dstSector,
- ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
- data[0],
- data[1],
- (Mode2Submode)data[2],
- data[3]);
+ Localization
+ .tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5,
+ dstSector,
+ ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
+ data[0],
+ data[1],
+ (Mode2Submode)data[2],
+ data[3]);
break;
case 2352 when data[0] != 0x00 ||
@@ -208,27 +206,27 @@ public sealed partial class ISO9660
break;
case 2352 when data[15] != 2:
AaruLogging.Debug(MODULE_NAME,
- Localization.tor_Sector_0_1_2_3_Raw_Mode_4,
- dstSector,
- data[12],
- data[13],
- data[14],
- data[15]);
+ Localization.tor_Sector_0_1_2_3_Raw_Mode_4,
+ dstSector,
+ data[12],
+ data[13],
+ data[14],
+ data[15]);
break;
case 2352:
AaruLogging.Debug(MODULE_NAME,
- Localization
- .tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8,
- dstSector,
- data[12],
- data[13],
- data[14],
- ((Mode2Submode)data[18]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
- data[16],
- data[17],
- (Mode2Submode)data[18],
- data[19]);
+ Localization
+ .tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8,
+ dstSector,
+ data[12],
+ data[13],
+ data[14],
+ ((Mode2Submode)data[18]).HasFlag(Mode2Submode.Form2) ? 2 : 1,
+ data[16],
+ data[17],
+ (Mode2Submode)data[18],
+ data[19]);
break;
}
@@ -239,7 +237,7 @@ public sealed partial class ISO9660
ms.Write(sectorData, 0, sectorData.Length);
}
- byte[] tmp = new byte[_blockSize];
+ var tmp = new byte[_blockSize];
Array.Copy(Sector.GetUserData(ms.ToArray(), interleaved, fileNumber), 0, tmp, 0, _blockSize);
buffer = tmp;
diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs
index 5d5628632..89a82181e 100644
--- a/Aaru.Filesystems/ISO9660/Super.cs
+++ b/Aaru.Filesystems/ISO9660/Super.cs
@@ -113,7 +113,7 @@ public sealed partial class ISO9660
ulong counter = 0;
- ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector);
+ ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -137,7 +137,7 @@ public sealed partial class ISO9660
// Seek to Volume Descriptor
AaruLogging.Debug(MODULE_NAME, Localization.Reading_sector_0, 16 + counter + partition.Start);
- errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp);
+ errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -422,8 +422,7 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return errno;
- CdiDirectoryRecord rootEntry =
- Marshal.ByteArrayToStructureBigEndian(firstRootSector);
+ CdiDirectoryRecord rootEntry = Marshal.ByteArrayToStructureBigEndian(firstRootSector);
rootSize = rootEntry.size;
diff --git a/Aaru.Filesystems/JFS/Info.cs b/Aaru.Filesystems/JFS/Info.cs
index 34c00868e..ea13d7e6f 100644
--- a/Aaru.Filesystems/JFS/Info.cs
+++ b/Aaru.Filesystems/JFS/Info.cs
@@ -50,7 +50,7 @@ public sealed partial class JFS
if(partition.Start + bootSectors >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -70,7 +70,7 @@ public sealed partial class JFS
metadata = new FileSystem();
var sb = new StringBuilder();
uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/LIF/Info.cs b/Aaru.Filesystems/LIF/Info.cs
index d9ef826d2..caeb43f9e 100644
--- a/Aaru.Filesystems/LIF/Info.cs
+++ b/Aaru.Filesystems/LIF/Info.cs
@@ -48,7 +48,7 @@ public sealed partial class LIF
{
if(imagePlugin.Info.SectorSize < 256) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -68,7 +68,7 @@ public sealed partial class LIF
if(imagePlugin.Info.SectorSize < 256) return;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/LisaFS/Dir.cs b/Aaru.Filesystems/LisaFS/Dir.cs
index a40d38852..2925c9a6a 100644
--- a/Aaru.Filesystems/LisaFS/Dir.cs
+++ b/Aaru.Filesystems/LisaFS/Dir.cs
@@ -44,89 +44,6 @@ namespace Aaru.Filesystems;
public sealed partial class LisaFS
{
-#region IReadOnlyFilesystem Members
-
- ///
- public ErrorNumber ReadLink(string path, out string dest)
- {
- dest = null;
-
- // LisaFS does not support symbolic links (afaik)
- return ErrorNumber.NotSupported;
- }
-
- ///
- public ErrorNumber OpenDir(string path, out IDirNode node)
- {
- node = null;
- ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
-
- if(error != ErrorNumber.NoError) return error;
-
- if(!isDir) return ErrorNumber.NotDirectory;
-
- /*List catalog;
- error = ReadCatalog(fileId, out catalog);
- if(error != ErrorNumber.NoError)
- return error;*/
-
- ReadDir(fileId, out List contents);
-
- // On debug add system files as readable files
- // Syntax similar to NTFS
- if(_debug && fileId == DIRID_ROOT)
- {
- contents.Add("$MDDF");
- contents.Add("$Boot");
- contents.Add("$Loader");
- contents.Add("$Bitmap");
- contents.Add("$S-Record");
- contents.Add("$");
- }
-
- contents.Sort();
-
- node = new LisaDirNode
- {
- Path = path,
- Contents = contents.ToArray(),
- Position = 0
- };
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber ReadDir(IDirNode node, out string filename)
- {
- filename = null;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- if(node is not LisaDirNode mynode) return ErrorNumber.InvalidArgument;
-
- if(mynode.Position < 0) return ErrorNumber.InvalidArgument;
-
- if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError;
-
- filename = mynode.Contents[mynode.Position++];
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber CloseDir(IDirNode node)
- {
- if(node is not LisaDirNode mynode) return ErrorNumber.InvalidArgument;
-
- mynode.Position = -1;
- mynode.Contents = null;
-
- return ErrorNumber.NoError;
- }
-
-#endregion
-
void ReadDir(short dirId, out List contents) =>
// Do same trick as Mac OS X, replace filesystem '/' with '-',
@@ -218,7 +135,7 @@ public sealed partial class LisaFS
if(catTag.FileId != FILEID_CATALOG || catTag.RelPage != 0) continue;
- errno = _device.ReadSectors(i, 4, out firstCatalogBlock);
+ errno = _device.ReadSectors(i, 4, out firstCatalogBlock, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -245,7 +162,8 @@ public sealed partial class LisaFS
errno = _device.ReadSectors(prevCatalogPointer + _mddf.mddf_block + _volumePrefix,
4,
- out firstCatalogBlock);
+ out firstCatalogBlock,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -271,7 +189,8 @@ public sealed partial class LisaFS
errno = _device.ReadSectors(nextCatalogPointer + _mddf.mddf_block + _volumePrefix,
4,
- out byte[] nextCatalogBlock);
+ out byte[] nextCatalogBlock,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -395,4 +314,87 @@ public sealed partial class LisaFS
return ErrorNumber.NoError;
}
+
+#region IReadOnlyFilesystem Members
+
+ ///
+ public ErrorNumber ReadLink(string path, out string dest)
+ {
+ dest = null;
+
+ // LisaFS does not support symbolic links (afaik)
+ return ErrorNumber.NotSupported;
+ }
+
+ ///
+ public ErrorNumber OpenDir(string path, out IDirNode node)
+ {
+ node = null;
+ ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
+
+ if(error != ErrorNumber.NoError) return error;
+
+ if(!isDir) return ErrorNumber.NotDirectory;
+
+ /*List catalog;
+ error = ReadCatalog(fileId, out catalog);
+ if(error != ErrorNumber.NoError)
+ return error;*/
+
+ ReadDir(fileId, out List contents);
+
+ // On debug add system files as readable files
+ // Syntax similar to NTFS
+ if(_debug && fileId == DIRID_ROOT)
+ {
+ contents.Add("$MDDF");
+ contents.Add("$Boot");
+ contents.Add("$Loader");
+ contents.Add("$Bitmap");
+ contents.Add("$S-Record");
+ contents.Add("$");
+ }
+
+ contents.Sort();
+
+ node = new LisaDirNode
+ {
+ Path = path,
+ Contents = contents.ToArray(),
+ Position = 0
+ };
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber ReadDir(IDirNode node, out string filename)
+ {
+ filename = null;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ if(node is not LisaDirNode mynode) return ErrorNumber.InvalidArgument;
+
+ if(mynode.Position < 0) return ErrorNumber.InvalidArgument;
+
+ if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError;
+
+ filename = mynode.Contents[mynode.Position++];
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber CloseDir(IDirNode node)
+ {
+ if(node is not LisaDirNode mynode) return ErrorNumber.InvalidArgument;
+
+ mynode.Position = -1;
+ mynode.Contents = null;
+
+ return ErrorNumber.NoError;
+ }
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs
index 4044f6d72..23be7f9df 100644
--- a/Aaru.Filesystems/LisaFS/Extent.cs
+++ b/Aaru.Filesystems/LisaFS/Extent.cs
@@ -102,8 +102,8 @@ public sealed partial class LisaFS
if(extTag.FileId != (short)(-1 * fileId)) return ErrorNumber.NoSuchFile;
errno = _mddf.fsversion == LISA_V1
- ? _device.ReadSectors(ptr, 2, out byte[] sector)
- : _device.ReadSector(ptr, out sector);
+ ? _device.ReadSectors(ptr, 2, out byte[] sector, out _)
+ : _device.ReadSector(ptr, out sector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -308,7 +308,8 @@ public sealed partial class LisaFS
// Searches the S-Records place using MDDF pointers
ErrorNumber errno = _device.ReadSectors(_mddf.srec_ptr + _mddf.mddf_block + _volumePrefix,
_mddf.srec_len,
- out byte[] sectors);
+ out byte[] sectors,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs
index 180f9628b..01d398be6 100644
--- a/Aaru.Filesystems/LisaFS/File.cs
+++ b/Aaru.Filesystems/LisaFS/File.cs
@@ -39,121 +39,6 @@ namespace Aaru.Filesystems;
public sealed partial class LisaFS
{
-#region IReadOnlyFilesystem Members
-
- ///
- public ErrorNumber GetAttributes(string path, out FileAttributes attributes)
- {
- attributes = new FileAttributes();
-
- ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
-
- if(error != ErrorNumber.NoError) return error;
-
- if(!isDir) return GetAttributes(fileId, out attributes);
-
- attributes = FileAttributes.Directory;
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber OpenFile(string path, out IFileNode node)
- {
- node = null;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
-
- if(error != ErrorNumber.NoError) return error;
-
- if(isDir) return ErrorNumber.IsDirectory;
-
- error = Stat(fileId, out FileEntryInfo stat);
-
- if(error != ErrorNumber.NoError) return error;
-
- node = new LisaFileNode
- {
- Path = path,
- Length = stat.Length,
- Offset = 0,
- FileId = fileId
- };
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber CloseFile(IFileNode node)
- {
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- return node is not LisaFileNode ? ErrorNumber.InvalidArgument : ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber ReadFile(IFileNode node, long length, byte[] buffer, out long read)
- {
- read = 0;
-
- if(!_mounted) return ErrorNumber.AccessDenied;
-
- if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument;
-
- if(node is not LisaFileNode mynode) return ErrorNumber.InvalidArgument;
-
- read = length;
-
- if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset;
-
- byte[] tmp;
- ErrorNumber error;
-
- if(_debug)
- {
- error = mynode.FileId switch
- {
- FILEID_BOOT_SIGNED
- or FILEID_LOADER_SIGNED
- or (short)FILEID_MDDF
- or (short)FILEID_BITMAP
- or (short)FILEID_SRECORD
- or (short)FILEID_CATALOG => ReadSystemFile(mynode.FileId, out tmp),
- _ => ReadFile(mynode.FileId, out tmp)
- };
- }
- else
- error = ReadFile(mynode.FileId, out tmp);
-
- if(error != ErrorNumber.NoError)
- {
- read = 0;
-
- return error;
- }
-
- Array.Copy(tmp, mynode.Offset, buffer, 0, read);
-
- mynode.Offset += read;
-
- return ErrorNumber.NoError;
- }
-
- ///
- public ErrorNumber Stat(string path, out FileEntryInfo stat)
- {
- stat = null;
- ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
-
- if(error != ErrorNumber.NoError) return error;
-
- return isDir ? StatDir(fileId, out stat) : Stat(fileId, out stat);
- }
-
-#endregion
-
ErrorNumber GetAttributes(short fileId, out FileAttributes attributes)
{
attributes = new FileAttributes();
@@ -220,9 +105,8 @@ public sealed partial class LisaFS
if(!_mounted || !_debug) return ErrorNumber.AccessDenied;
if(fileId is > 4 or <= 0)
- {
- if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return ErrorNumber.InvalidArgument;
- }
+ if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED)
+ return ErrorNumber.InvalidArgument;
if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) return ErrorNumber.NoError;
@@ -232,7 +116,10 @@ public sealed partial class LisaFS
{
if(!tags)
{
- errno = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, out buf);
+ errno = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr,
+ _mddf.srec_len,
+ out buf,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -279,7 +166,7 @@ public sealed partial class LisaFS
if(sysTag.FileId != fileId) continue;
errno = !tags
- ? _device.ReadSector(i, out byte[] sector)
+ ? _device.ReadSector(i, out byte[] sector, out _)
: _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out sector);
if(errno != ErrorNumber.NoError) continue;
@@ -420,7 +307,8 @@ public sealed partial class LisaFS
_mddf.mddf_block +
_volumePrefix,
(uint)file.extents[i].length,
- out byte[] sector)
+ out byte[] sector,
+ out _)
: _device.ReadSectorsTag((ulong)file.extents[i].start +
_mddf.mddf_block +
_volumePrefix,
@@ -437,9 +325,8 @@ public sealed partial class LisaFS
if(!tags)
{
if(_fileSizeCache.TryGetValue(fileId, out int realSize))
- {
- if(realSize > temp.Length) AaruLogging.Error(Localization.File_0_gets_truncated, fileId);
- }
+ if(realSize > temp.Length)
+ AaruLogging.Error(Localization.File_0_gets_truncated, fileId);
buf = temp;
@@ -549,4 +436,119 @@ public sealed partial class LisaFS
return ErrorNumber.NoSuchFile;
}
+
+#region IReadOnlyFilesystem Members
+
+ ///
+ public ErrorNumber GetAttributes(string path, out FileAttributes attributes)
+ {
+ attributes = new FileAttributes();
+
+ ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
+
+ if(error != ErrorNumber.NoError) return error;
+
+ if(!isDir) return GetAttributes(fileId, out attributes);
+
+ attributes = FileAttributes.Directory;
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber OpenFile(string path, out IFileNode node)
+ {
+ node = null;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
+
+ if(error != ErrorNumber.NoError) return error;
+
+ if(isDir) return ErrorNumber.IsDirectory;
+
+ error = Stat(fileId, out FileEntryInfo stat);
+
+ if(error != ErrorNumber.NoError) return error;
+
+ node = new LisaFileNode
+ {
+ Path = path,
+ Length = stat.Length,
+ Offset = 0,
+ FileId = fileId
+ };
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber CloseFile(IFileNode node)
+ {
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ return node is not LisaFileNode ? ErrorNumber.InvalidArgument : ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber ReadFile(IFileNode node, long length, byte[] buffer, out long read)
+ {
+ read = 0;
+
+ if(!_mounted) return ErrorNumber.AccessDenied;
+
+ if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument;
+
+ if(node is not LisaFileNode mynode) return ErrorNumber.InvalidArgument;
+
+ read = length;
+
+ if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset;
+
+ byte[] tmp;
+ ErrorNumber error;
+
+ if(_debug)
+ {
+ error = mynode.FileId switch
+ {
+ FILEID_BOOT_SIGNED
+ or FILEID_LOADER_SIGNED
+ or (short)FILEID_MDDF
+ or (short)FILEID_BITMAP
+ or (short)FILEID_SRECORD
+ or (short)FILEID_CATALOG => ReadSystemFile(mynode.FileId, out tmp),
+ _ => ReadFile(mynode.FileId, out tmp)
+ };
+ }
+ else
+ error = ReadFile(mynode.FileId, out tmp);
+
+ if(error != ErrorNumber.NoError)
+ {
+ read = 0;
+
+ return error;
+ }
+
+ Array.Copy(tmp, mynode.Offset, buffer, 0, read);
+
+ mynode.Offset += read;
+
+ return ErrorNumber.NoError;
+ }
+
+ ///
+ public ErrorNumber Stat(string path, out FileEntryInfo stat)
+ {
+ stat = null;
+ ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir);
+
+ if(error != ErrorNumber.NoError) return error;
+
+ return isDir ? StatDir(fileId, out stat) : Stat(fileId, out stat);
+ }
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/LisaFS/Info.cs b/Aaru.Filesystems/LisaFS/Info.cs
index 95d945878..ac22ccc7d 100644
--- a/Aaru.Filesystems/LisaFS/Info.cs
+++ b/Aaru.Filesystems/LisaFS/Info.cs
@@ -69,7 +69,7 @@ public sealed partial class LisaFS
if(searchTag.FileId != FILEID_MDDF) continue;
- errno = imagePlugin.ReadSector((ulong)i, out byte[] sector);
+ errno = imagePlugin.ReadSector((ulong)i, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -146,7 +146,7 @@ public sealed partial class LisaFS
if(searchTag.FileId != FILEID_MDDF) continue;
- errno = imagePlugin.ReadSector((ulong)i, out byte[] sector);
+ errno = imagePlugin.ReadSector((ulong)i, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) continue;
diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs
index b15f1457f..450ddb8df 100644
--- a/Aaru.Filesystems/LisaFS/Super.cs
+++ b/Aaru.Filesystems/LisaFS/Super.cs
@@ -92,7 +92,7 @@ public sealed partial class LisaFS
if(searchTag.FileId != FILEID_MDDF) continue;
_devTagSize = tag.Length;
- errno = _device.ReadSector(i, out byte[] sector);
+ errno = _device.ReadSector(i, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return errno;
diff --git a/Aaru.Filesystems/Locus/Info.cs b/Aaru.Filesystems/Locus/Info.cs
index ea95e2733..d4c8c4930 100644
--- a/Aaru.Filesystems/Locus/Info.cs
+++ b/Aaru.Filesystems/Locus/Info.cs
@@ -72,7 +72,7 @@ public sealed partial class Locus
if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -107,7 +107,7 @@ public sealed partial class Locus
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out sector, out _);
if(errno != ErrorNumber.NoError) continue;
diff --git a/Aaru.Filesystems/MicroDOS/Info.cs b/Aaru.Filesystems/MicroDOS/Info.cs
index bdc9a0221..133fe3df9 100644
--- a/Aaru.Filesystems/MicroDOS/Info.cs
+++ b/Aaru.Filesystems/MicroDOS/Info.cs
@@ -54,7 +54,7 @@ public sealed partial class MicroDOS
if(imagePlugin.Info.SectorSize < 512) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -72,7 +72,7 @@ public sealed partial class MicroDOS
var sb = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/MinixFS/Info.cs b/Aaru.Filesystems/MinixFS/Info.cs
index b6221202b..53d5be88d 100644
--- a/Aaru.Filesystems/MinixFS/Info.cs
+++ b/Aaru.Filesystems/MinixFS/Info.cs
@@ -57,7 +57,7 @@ public sealed partial class MinixFS
if(sector + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -107,7 +107,7 @@ public sealed partial class MinixFS
var minix3 = false;
int filenamesize;
string minixVersion;
- ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/NILFS2/Info.cs b/Aaru.Filesystems/NILFS2/Info.cs
index 83de22355..d3a4acb42 100644
--- a/Aaru.Filesystems/NILFS2/Info.cs
+++ b/Aaru.Filesystems/NILFS2/Info.cs
@@ -58,7 +58,7 @@ public sealed partial class NILFS2
if(partition.Start + sbAddr + sbSize >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -87,7 +87,7 @@ public sealed partial class NILFS2
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/NTFS/Info.cs b/Aaru.Filesystems/NTFS/Info.cs
index 8fb289ae3..f332c8c8d 100644
--- a/Aaru.Filesystems/NTFS/Info.cs
+++ b/Aaru.Filesystems/NTFS/Info.cs
@@ -51,7 +51,7 @@ public sealed partial class NTFS
var eigthBytes = new byte[8];
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -80,7 +80,7 @@ public sealed partial class NTFS
var sb = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/Nintendo/Info.cs b/Aaru.Filesystems/Nintendo/Info.cs
index d64d32d10..eb97171c0 100644
--- a/Aaru.Filesystems/Nintendo/Info.cs
+++ b/Aaru.Filesystems/Nintendo/Info.cs
@@ -50,12 +50,12 @@ public sealed partial class NintendoPlugin
if(imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize < 0x50000) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header);
+ ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header, out _);
if(errno != ErrorNumber.NoError) return false;
- uint magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C);
- uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18);
+ var magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C);
+ var magicWii = BigEndianBitConverter.ToUInt32(header, 0x18);
return magicGc == 0xC2339F3D || magicWii == 0x5D1C9EA3;
}
@@ -71,14 +71,14 @@ public sealed partial class NintendoPlugin
var fields = new NintendoFields();
- ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header);
+ ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header, out _);
if(errno != ErrorNumber.NoError) return;
- bool wii = false;
+ var wii = false;
- uint magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C);
- uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18);
+ var magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C);
+ var magicWii = BigEndianBitConverter.ToUInt32(header, 0x18);
if(magicWii == 0x5D1C9EA3)
wii = true;
@@ -93,7 +93,7 @@ public sealed partial class NintendoPlugin
fields.DiscVersion = header[7];
fields.Streaming |= header[8] > 0;
fields.StreamBufferSize = header[9];
- byte[] temp = new byte[64];
+ var temp = new byte[64];
Array.Copy(header, 0x20, temp, 0, 64);
fields.Title = StringHandlers.CToString(temp, encoding);
@@ -119,7 +119,7 @@ public sealed partial class NintendoPlugin
fields.ThirdPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40010)];
fields.FourthPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40018)];
- for(int i = 0; i < fields.FirstPartitions.Length; i++)
+ for(var i = 0; i < fields.FirstPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 >= 0x50000) continue;
@@ -129,7 +129,7 @@ public sealed partial class NintendoPlugin
fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 4));
}
- for(int i = 0; i < fields.SecondPartitions.Length; i++)
+ for(var i = 0; i < fields.SecondPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 >= 0x50000) continue;
@@ -139,7 +139,7 @@ public sealed partial class NintendoPlugin
fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 4));
}
- for(int i = 0; i < fields.ThirdPartitions.Length; i++)
+ for(var i = 0; i < fields.ThirdPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 >= 0x50000) continue;
@@ -149,7 +149,7 @@ public sealed partial class NintendoPlugin
fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 4));
}
- for(int i = 0; i < fields.FourthPartitions.Length; i++)
+ for(var i = 0; i < fields.FourthPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 >= 0x50000) continue;
@@ -195,56 +195,32 @@ public sealed partial class NintendoPlugin
AaruLogging.Debug(MODULE_NAME, "fstSize = {0}", fields.FstSize);
AaruLogging.Debug(MODULE_NAME, "fstMax = {0}", fields.FstMax);
- for(int i = 0; i < fields.FirstPartitions.Length; i++)
+ for(var i = 0; i < fields.FirstPartitions.Length; i++)
{
- AaruLogging.Debug(MODULE_NAME,
- "firstPartitions[{1}].offset = {0}",
- fields.FirstPartitions[i].Offset,
- i);
+ AaruLogging.Debug(MODULE_NAME, "firstPartitions[{1}].offset = {0}", fields.FirstPartitions[i].Offset, i);
- AaruLogging.Debug(MODULE_NAME,
- "firstPartitions[{1}].type = {0}",
- fields.FirstPartitions[i].Type,
- i);
+ AaruLogging.Debug(MODULE_NAME, "firstPartitions[{1}].type = {0}", fields.FirstPartitions[i].Type, i);
}
- for(int i = 0; i < fields.SecondPartitions.Length; i++)
+ for(var i = 0; i < fields.SecondPartitions.Length; i++)
{
- AaruLogging.Debug(MODULE_NAME,
- "secondPartitions[{1}].offset = {0}",
- fields.SecondPartitions[i].Offset,
- i);
+ AaruLogging.Debug(MODULE_NAME, "secondPartitions[{1}].offset = {0}", fields.SecondPartitions[i].Offset, i);
- AaruLogging.Debug(MODULE_NAME,
- "secondPartitions[{1}].type = {0}",
- fields.SecondPartitions[i].Type,
- i);
+ AaruLogging.Debug(MODULE_NAME, "secondPartitions[{1}].type = {0}", fields.SecondPartitions[i].Type, i);
}
- for(int i = 0; i < fields.ThirdPartitions.Length; i++)
+ for(var i = 0; i < fields.ThirdPartitions.Length; i++)
{
- AaruLogging.Debug(MODULE_NAME,
- "thirdPartitions[{1}].offset = {0}",
- fields.ThirdPartitions[i].Offset,
- i);
+ AaruLogging.Debug(MODULE_NAME, "thirdPartitions[{1}].offset = {0}", fields.ThirdPartitions[i].Offset, i);
- AaruLogging.Debug(MODULE_NAME,
- "thirdPartitions[{1}].type = {0}",
- fields.ThirdPartitions[i].Type,
- i);
+ AaruLogging.Debug(MODULE_NAME, "thirdPartitions[{1}].type = {0}", fields.ThirdPartitions[i].Type, i);
}
- for(int i = 0; i < fields.FourthPartitions.Length; i++)
+ for(var i = 0; i < fields.FourthPartitions.Length; i++)
{
- AaruLogging.Debug(MODULE_NAME,
- "fourthPartitions[{1}].offset = {0}",
- fields.FourthPartitions[i].Offset,
- i);
+ AaruLogging.Debug(MODULE_NAME, "fourthPartitions[{1}].offset = {0}", fields.FourthPartitions[i].Offset, i);
- AaruLogging.Debug(MODULE_NAME,
- "fourthPartitions[{1}].type = {0}",
- fields.FourthPartitions[i].Type,
- i);
+ AaruLogging.Debug(MODULE_NAME, "fourthPartitions[{1}].type = {0}", fields.FourthPartitions[i].Type, i);
}
AaruLogging.Debug(MODULE_NAME, "region = {0}", fields.Region);
@@ -289,7 +265,7 @@ public sealed partial class NintendoPlugin
if(wii)
{
- for(int i = 0; i < fields.FirstPartitions.Length; i++)
+ for(var i = 0; i < fields.FirstPartitions.Length; i++)
{
sbInformation.AppendFormat(Localization.First_0_partition_starts_at_sector_1,
PartitionTypeToString(fields.FirstPartitions[i].Type),
@@ -297,7 +273,7 @@ public sealed partial class NintendoPlugin
.AppendLine();
}
- for(int i = 0; i < fields.SecondPartitions.Length; i++)
+ for(var i = 0; i < fields.SecondPartitions.Length; i++)
{
sbInformation.AppendFormat(Localization.Second_0_partition_starts_at_sector_1,
PartitionTypeToString(fields.SecondPartitions[i].Type),
@@ -305,7 +281,7 @@ public sealed partial class NintendoPlugin
.AppendLine();
}
- for(int i = 0; i < fields.ThirdPartitions.Length; i++)
+ for(var i = 0; i < fields.ThirdPartitions.Length; i++)
{
sbInformation.AppendFormat(Localization.Third_0_partition_starts_at_sector_1,
PartitionTypeToString(fields.ThirdPartitions[i].Type),
@@ -313,7 +289,7 @@ public sealed partial class NintendoPlugin
.AppendLine();
}
- for(int i = 0; i < fields.FourthPartitions.Length; i++)
+ for(var i = 0; i < fields.FourthPartitions.Length; i++)
{
sbInformation.AppendFormat(Localization.Fourth_0_partition_starts_at_sector_1,
PartitionTypeToString(fields.FourthPartitions[i].Type),
diff --git a/Aaru.Filesystems/ODS/Info.cs b/Aaru.Filesystems/ODS/Info.cs
index 63047ec68..6917fd2ed 100644
--- a/Aaru.Filesystems/ODS/Info.cs
+++ b/Aaru.Filesystems/ODS/Info.cs
@@ -63,8 +63,8 @@ public sealed partial class ODS
if(imagePlugin.Info.SectorSize < 512) return false;
- byte[] magicB = new byte[12];
- ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector);
+ var magicB = new byte[12];
+ ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -80,7 +80,7 @@ public sealed partial class ODS
if(hbSector.Length < 0x400) return false;
- errno = imagePlugin.ReadSector(partition.Start, out hbSector);
+ errno = imagePlugin.ReadSector(partition.Start, out hbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -102,7 +102,7 @@ public sealed partial class ODS
var sb = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -115,7 +115,7 @@ public sealed partial class ODS
{
if(hbSector.Length < 0x400) return;
- errno = imagePlugin.ReadSector(partition.Start, out byte[] tmp);
+ errno = imagePlugin.ReadSector(partition.Start, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs
index 19aa7666f..460682a85 100644
--- a/Aaru.Filesystems/Opera/Dir.cs
+++ b/Aaru.Filesystems/Opera/Dir.cs
@@ -38,6 +38,62 @@ namespace Aaru.Filesystems;
public sealed partial class OperaFS
{
+ Dictionary DecodeDirectory(int firstBlock)
+ {
+ Dictionary entries = new();
+
+ int nextBlock = firstBlock;
+
+ DirectoryHeader header;
+
+ do
+ {
+ ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio),
+ _volumeBlockSizeRatio,
+ out byte[] data,
+ out _);
+
+ if(errno != ErrorNumber.NoError) break;
+
+ header = Marshal.ByteArrayToStructureBigEndian(data);
+ nextBlock = header.next_block + firstBlock;
+
+ var off = (int)header.first_used;
+
+ var entry = new DirectoryEntry();
+
+ while(off + _directoryEntrySize < data.Length)
+ {
+ entry = Marshal.ByteArrayToStructureBigEndian(data, off, _directoryEntrySize);
+ string name = StringHandlers.CToString(entry.name, _encoding);
+
+ var entryWithPointers = new DirectoryEntryWithPointers
+ {
+ Entry = entry,
+ Pointers = new uint[entry.last_copy + 1]
+ };
+
+ for(var i = 0; i <= entry.last_copy; i++)
+ {
+ entryWithPointers.Pointers[i] =
+ BigEndianBitConverter.ToUInt32(data, off + _directoryEntrySize + i * 4);
+ }
+
+ entries.Add(name, entryWithPointers);
+
+ if((entry.flags & (uint)FileFlags.LastEntry) != 0 ||
+ (entry.flags & (uint)FileFlags.LastEntryInBlock) != 0)
+ break;
+
+ off += (int)(_directoryEntrySize + (entry.last_copy + 1) * 4);
+ }
+
+ if((entry.flags & (uint)FileFlags.LastEntry) != 0) break;
+ } while(header.next_block != -1);
+
+ return entries;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -154,59 +210,4 @@ public sealed partial class OperaFS
}
#endregion
-
- Dictionary DecodeDirectory(int firstBlock)
- {
- Dictionary entries = new();
-
- int nextBlock = firstBlock;
-
- DirectoryHeader header;
-
- do
- {
- ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio),
- _volumeBlockSizeRatio,
- out byte[] data);
-
- if(errno != ErrorNumber.NoError) break;
-
- header = Marshal.ByteArrayToStructureBigEndian(data);
- nextBlock = header.next_block + firstBlock;
-
- var off = (int)header.first_used;
-
- var entry = new DirectoryEntry();
-
- while(off + _directoryEntrySize < data.Length)
- {
- entry = Marshal.ByteArrayToStructureBigEndian(data, off, _directoryEntrySize);
- string name = StringHandlers.CToString(entry.name, _encoding);
-
- var entryWithPointers = new DirectoryEntryWithPointers
- {
- Entry = entry,
- Pointers = new uint[entry.last_copy + 1]
- };
-
- for(var i = 0; i <= entry.last_copy; i++)
- {
- entryWithPointers.Pointers[i] =
- BigEndianBitConverter.ToUInt32(data, off + _directoryEntrySize + i * 4);
- }
-
- entries.Add(name, entryWithPointers);
-
- if((entry.flags & (uint)FileFlags.LastEntry) != 0 ||
- (entry.flags & (uint)FileFlags.LastEntryInBlock) != 0)
- break;
-
- off += (int)(_directoryEntrySize + (entry.last_copy + 1) * 4);
- }
-
- if((entry.flags & (uint)FileFlags.LastEntry) != 0) break;
- } while(header.next_block != -1);
-
- return entries;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs
index 8f6811b2a..4260c04cd 100644
--- a/Aaru.Filesystems/Opera/File.cs
+++ b/Aaru.Filesystems/Opera/File.cs
@@ -39,6 +39,49 @@ namespace Aaru.Filesystems;
public sealed partial class OperaFS
{
+ ErrorNumber GetFileEntry(string path, out DirectoryEntryWithPointers entry)
+ {
+ entry = null;
+
+ string cutPath = path.StartsWith("/", StringComparison.Ordinal)
+ ? path[1..].ToLower(CultureInfo.CurrentUICulture)
+ : path.ToLower(CultureInfo.CurrentUICulture);
+
+ string[] pieces = cutPath.Split(new[]
+ {
+ '/'
+ },
+ StringSplitOptions.RemoveEmptyEntries);
+
+ if(pieces.Length == 0) return ErrorNumber.InvalidArgument;
+
+ var parentPath = string.Join("/", pieces, 0, pieces.Length - 1);
+
+ if(!_directoryCache.TryGetValue(parentPath, out _))
+ {
+ ErrorNumber err = OpenDir(parentPath, out IDirNode node);
+
+ if(err != ErrorNumber.NoError) return err;
+
+ CloseDir(node);
+ }
+
+ Dictionary parent;
+
+ if(pieces.Length == 1)
+ parent = _rootDirectoryCache;
+ else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument;
+
+ KeyValuePair dirent =
+ parent.FirstOrDefault(t => t.Key.Equals(pieces[^1], StringComparison.CurrentCultureIgnoreCase));
+
+ if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile;
+
+ entry = dirent.Value;
+
+ return ErrorNumber.NoError;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -121,7 +164,8 @@ public sealed partial class OperaFS
ErrorNumber errno = _image.ReadSectors((ulong)(mynode.Dentry.Pointers[0] + firstBlock * fileBlockSizeRatio),
(uint)(sizeInBlocks * fileBlockSizeRatio),
- out byte[] buf);
+ out byte[] buf,
+ out _);
if(errno != ErrorNumber.NoError)
{
@@ -178,47 +222,4 @@ public sealed partial class OperaFS
}
#endregion
-
- ErrorNumber GetFileEntry(string path, out DirectoryEntryWithPointers entry)
- {
- entry = null;
-
- string cutPath = path.StartsWith("/", StringComparison.Ordinal)
- ? path[1..].ToLower(CultureInfo.CurrentUICulture)
- : path.ToLower(CultureInfo.CurrentUICulture);
-
- string[] pieces = cutPath.Split(new[]
- {
- '/'
- },
- StringSplitOptions.RemoveEmptyEntries);
-
- if(pieces.Length == 0) return ErrorNumber.InvalidArgument;
-
- string parentPath = string.Join("/", pieces, 0, pieces.Length - 1);
-
- if(!_directoryCache.TryGetValue(parentPath, out _))
- {
- ErrorNumber err = OpenDir(parentPath, out IDirNode node);
-
- if(err != ErrorNumber.NoError) return err;
-
- CloseDir(node);
- }
-
- Dictionary parent;
-
- if(pieces.Length == 1)
- parent = _rootDirectoryCache;
- else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument;
-
- KeyValuePair dirent =
- parent.FirstOrDefault(t => t.Key.Equals(pieces[^1], StringComparison.CurrentCultureIgnoreCase));
-
- if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile;
-
- entry = dirent.Value;
-
- return ErrorNumber.NoError;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs
index 72a476e00..c12914b6e 100644
--- a/Aaru.Filesystems/Opera/Info.cs
+++ b/Aaru.Filesystems/Opera/Info.cs
@@ -45,7 +45,7 @@ public sealed partial class OperaFS
{
if(2 + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -70,7 +70,7 @@ public sealed partial class OperaFS
metadata = new FileSystem();
var superBlockmetadata = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs
index 54a216de0..561abff57 100644
--- a/Aaru.Filesystems/Opera/Super.cs
+++ b/Aaru.Filesystems/Opera/Super.cs
@@ -53,7 +53,7 @@ public sealed partial class OperaFS
if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug);
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -93,7 +93,7 @@ public sealed partial class OperaFS
};
_image = imagePlugin;
- int firstRootBlock = BigEndianBitConverter.ToInt32(sbSector, Marshal.SizeOf());
+ var firstRootBlock = BigEndianBitConverter.ToInt32(sbSector, Marshal.SizeOf());
_rootDirectoryCache = DecodeDirectory(firstRootBlock);
_directoryCache = new Dictionary>();
_mounted = true;
diff --git a/Aaru.Filesystems/PCEngine/Info.cs b/Aaru.Filesystems/PCEngine/Info.cs
index da0d1cc08..e1e3c0af7 100644
--- a/Aaru.Filesystems/PCEngine/Info.cs
+++ b/Aaru.Filesystems/PCEngine/Info.cs
@@ -51,7 +51,7 @@ public sealed partial class PCEnginePlugin
if(2 + partition.Start >= partition.End) return false;
var systemDescriptor = new byte[23];
- ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
diff --git a/Aaru.Filesystems/PCFX/Info.cs b/Aaru.Filesystems/PCFX/Info.cs
index 6b654c516..1395c8eb4 100644
--- a/Aaru.Filesystems/PCFX/Info.cs
+++ b/Aaru.Filesystems/PCFX/Info.cs
@@ -54,7 +54,7 @@ public sealed partial class PCFX
if(2 + partition.Start >= partition.End || imagePlugin.Info.MetadataMediaType != MetadataMediaType.OpticalDisc)
return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -72,7 +72,7 @@ public sealed partial class PCFX
information = "";
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -84,9 +84,9 @@ public sealed partial class PCFX
try
{
date = encoding.GetString(header.date);
- int year = int.Parse(date[..4]);
- int month = int.Parse(date.Substring(4, 2));
- int day = int.Parse(date.Substring(6, 2));
+ var year = int.Parse(date[..4]);
+ var month = int.Parse(date.Substring(4, 2));
+ var day = int.Parse(date.Substring(6, 2));
dateTime = new DateTime(year, month, day);
}
catch(Exception ex)
diff --git a/Aaru.Filesystems/PFS/Info.cs b/Aaru.Filesystems/PFS/Info.cs
index d8d1550b3..d3411b0d1 100644
--- a/Aaru.Filesystems/PFS/Info.cs
+++ b/Aaru.Filesystems/PFS/Info.cs
@@ -48,7 +48,7 @@ public sealed partial class PFS
{
if(partition.Length < 3) return false;
- ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -64,7 +64,7 @@ public sealed partial class PFS
information = "";
encoding ??= Encoding.GetEncoding("iso-8859-1");
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] rootBlockSector);
+ ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] rootBlockSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/ProDOS/Info.cs b/Aaru.Filesystems/ProDOS/Info.cs
index b1bc09037..35d965fb2 100644
--- a/Aaru.Filesystems/ProDOS/Info.cs
+++ b/Aaru.Filesystems/ProDOS/Info.cs
@@ -56,19 +56,21 @@ public sealed partial class ProDOSPlugin
{
if(partition.Length < 3) return false;
- uint multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
+ var multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
// Blocks 0 and 1 are boot code
- ErrorNumber errno =
- imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier, out byte[] rootDirectoryKeyBlock);
+ ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start,
+ multiplier,
+ out byte[] rootDirectoryKeyBlock,
+ out _);
if(errno != ErrorNumber.NoError) return false;
- bool apmFromHddOnCd = false;
+ var apmFromHddOnCd = false;
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)
{
- errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp);
+ errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -88,12 +90,12 @@ public sealed partial class ProDOSPlugin
}
}
- ushort prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0);
+ var prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0);
AaruLogging.Debug(MODULE_NAME, "prePointer = {0}", prePointer);
if(prePointer != 0) return false;
- byte storageType = (byte)((rootDirectoryKeyBlock[0x04] & STORAGE_TYPE_MASK) >> 4);
+ var storageType = (byte)((rootDirectoryKeyBlock[0x04] & STORAGE_TYPE_MASK) >> 4);
AaruLogging.Debug(MODULE_NAME, "storage_type = {0}", storageType);
if(storageType != ROOT_DIRECTORY_TYPE) return false;
@@ -108,21 +110,21 @@ public sealed partial class ProDOSPlugin
if(entriesPerBlock != ENTRIES_PER_BLOCK) return false;
- ushort bitMapPointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27);
+ var bitMapPointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27);
AaruLogging.Debug(MODULE_NAME, "bit_map_pointer = {0}", bitMapPointer);
if(bitMapPointer > partition.End) return false;
- ushort totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29);
+ var totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29);
if(apmFromHddOnCd) totalBlocks /= 4;
AaruLogging.Debug(MODULE_NAME,
- "{0} <= ({1} - {2} + 1)? {3}",
- totalBlocks,
- partition.End,
- partition.Start,
- totalBlocks <= partition.End - partition.Start + 1);
+ "{0} <= ({1} - {2} + 1)? {3}",
+ totalBlocks,
+ partition.End,
+ partition.Start,
+ totalBlocks <= partition.End - partition.Start + 1);
return totalBlocks <= partition.End - partition.Start + 1;
}
@@ -134,21 +136,22 @@ public sealed partial class ProDOSPlugin
encoding ??= new Apple2c();
information = "";
metadata = new FileSystem();
- var sbInformation = new StringBuilder();
- uint multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
+ var sbInformation = new StringBuilder();
+ var multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
// Blocks 0 and 1 are boot code
ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start,
multiplier,
- out byte[] rootDirectoryKeyBlockBytes);
+ out byte[] rootDirectoryKeyBlockBytes,
+ out _);
if(errno != ErrorNumber.NoError) return;
- bool apmFromHddOnCd = false;
+ var apmFromHddOnCd = false;
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)
{
- errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp);
+ errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return;
@@ -177,24 +180,24 @@ public sealed partial class ProDOSPlugin
rootDirectoryKeyBlock.header.storage_type = (byte)((rootDirectoryKeyBlockBytes[0x04] & STORAGE_TYPE_MASK) >> 4);
rootDirectoryKeyBlock.header.name_length = (byte)(rootDirectoryKeyBlockBytes[0x04] & NAME_LENGTH_MASK);
- byte[] temporal = new byte[rootDirectoryKeyBlock.header.name_length];
+ var temporal = new byte[rootDirectoryKeyBlock.header.name_length];
Array.Copy(rootDirectoryKeyBlockBytes, 0x05, temporal, 0, rootDirectoryKeyBlock.header.name_length);
rootDirectoryKeyBlock.header.volume_name = encoding.GetString(temporal);
rootDirectoryKeyBlock.header.reserved = BitConverter.ToUInt64(rootDirectoryKeyBlockBytes, 0x14);
- ushort tempTimestampLeft = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C);
- ushort tempTimestampRight = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1E);
+ var tempTimestampLeft = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C);
+ var tempTimestampRight = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1E);
bool dateCorrect;
try
{
- uint tempTimestamp = (uint)((tempTimestampLeft << 16) + tempTimestampRight);
- int year = (int)((tempTimestamp & YEAR_MASK) >> 25);
- int month = (int)((tempTimestamp & MONTH_MASK) >> 21);
- int day = (int)((tempTimestamp & DAY_MASK) >> 16);
- int hour = (int)((tempTimestamp & HOUR_MASK) >> 8);
- int minute = (int)(tempTimestamp & MINUTE_MASK);
+ var tempTimestamp = (uint)((tempTimestampLeft << 16) + tempTimestampRight);
+ var year = (int)((tempTimestamp & YEAR_MASK) >> 25);
+ var month = (int)((tempTimestamp & MONTH_MASK) >> 21);
+ var day = (int)((tempTimestamp & DAY_MASK) >> 16);
+ var hour = (int)((tempTimestamp & HOUR_MASK) >> 8);
+ var minute = (int)(tempTimestamp & MINUTE_MASK);
year += 1900;
if(year < 1940) year += 100;
@@ -204,12 +207,12 @@ public sealed partial class ProDOSPlugin
AaruLogging.Debug(MODULE_NAME, "temp_timestamp = 0x{0:X8}", tempTimestamp);
AaruLogging.Debug(MODULE_NAME,
- Localization.Datetime_field_year_0_month_1_day_2_hour_3_minute_4,
- year,
- month,
- day,
- hour,
- minute);
+ Localization.Datetime_field_year_0_month_1_day_2_hour_3_minute_4,
+ year,
+ month,
+ day,
+ hour,
+ minute);
rootDirectoryKeyBlock.header.creation_time = new DateTime(year, month, day, hour, minute, 0);
dateCorrect = true;
@@ -305,8 +308,8 @@ public sealed partial class ProDOSPlugin
if((rootDirectoryKeyBlock.header.access & RESERVED_ATTRIBUTE_MASK) != 0)
{
AaruLogging.Debug(MODULE_NAME,
- Localization.Reserved_attributes_are_set_0,
- rootDirectoryKeyBlock.header.access);
+ Localization.Reserved_attributes_are_set_0,
+ rootDirectoryKeyBlock.header.access);
}
information = sbInformation.ToString();
diff --git a/Aaru.Filesystems/QNX4/Info.cs b/Aaru.Filesystems/QNX4/Info.cs
index 492779288..5b617ebde 100644
--- a/Aaru.Filesystems/QNX4/Info.cs
+++ b/Aaru.Filesystems/QNX4/Info.cs
@@ -49,7 +49,7 @@ public sealed partial class QNX4
{
if(partition.Start + 1 >= imagePlugin.Info.Sectors) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -88,7 +88,7 @@ public sealed partial class QNX4
{
information = "";
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/QNX6/Info.cs b/Aaru.Filesystems/QNX6/Info.cs
index 9a313edab..37253bf7e 100644
--- a/Aaru.Filesystems/QNX6/Info.cs
+++ b/Aaru.Filesystems/QNX6/Info.cs
@@ -49,11 +49,11 @@ public sealed partial class QNX6
if(partition.Start + bootSectors + sectors >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector, out _);
if(errno != ErrorNumber.NoError) return false;
- errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector);
+ errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -76,11 +76,11 @@ public sealed partial class QNX6
uint sectors = QNX6_SUPER_BLOCK_SIZE / imagePlugin.Info.SectorSize;
uint bootSectors = QNX6_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector, out _);
if(errno != ErrorNumber.NoError) return;
- errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector);
+ errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/RBF/Info.cs b/Aaru.Filesystems/RBF/Info.cs
index 3c9728dfe..bf6dcf441 100644
--- a/Aaru.Filesystems/RBF/Info.cs
+++ b/Aaru.Filesystems/RBF/Info.cs
@@ -55,15 +55,15 @@ public sealed partial class RBF
0, 4, 15
})
{
- ulong location = (ulong)i;
+ var location = (ulong)i;
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -73,12 +73,12 @@ public sealed partial class RBF
NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_or_2_expected_3_or_4,
- location,
- rbfSb.dd_sync,
- rbf9000Sb.rid_sync,
- RBF_SYNC,
- RBF_CNYS);
+ Localization.magic_at_0_equals_1_or_2_expected_3_or_4,
+ location,
+ rbfSb.dd_sync,
+ rbf9000Sb.rid_sync,
+ RBF_SYNC,
+ RBF_CNYS);
if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync is RBF_SYNC or RBF_CNYS) return true;
}
@@ -104,12 +104,12 @@ public sealed partial class RBF
0, 4, 15
})
{
- ulong location = (ulong)i;
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var location = (ulong)i;
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -119,12 +119,12 @@ public sealed partial class RBF
rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_or_2_expected_3_or_4,
- location,
- rbfSb.dd_sync,
- rbf9000Sb.rid_sync,
- RBF_SYNC,
- RBF_CNYS);
+ Localization.magic_at_0_equals_1_or_2_expected_3_or_4,
+ location,
+ rbfSb.dd_sync,
+ rbf9000Sb.rid_sync,
+ RBF_SYNC,
+ RBF_CNYS);
if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync is RBF_SYNC or RBF_CNYS) break;
}
diff --git a/Aaru.Filesystems/RT11/Info.cs b/Aaru.Filesystems/RT11/Info.cs
index 1277e2543..f67f302ec 100644
--- a/Aaru.Filesystems/RT11/Info.cs
+++ b/Aaru.Filesystems/RT11/Info.cs
@@ -55,7 +55,7 @@ public sealed partial class RT11
if(1 + partition.Start >= partition.End) return false;
var magicB = new byte[12];
- ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -77,7 +77,7 @@ public sealed partial class RT11
var sb = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -108,7 +108,7 @@ public sealed partial class RT11
sb.AppendFormat(Localization.Volume_label_0, encoding.GetString(homeblock.volname).TrimEnd()).AppendLine();
sb.AppendFormat(Localization.Checksum_0_calculated_1, homeblock.checksum, check).AppendLine();
- imagePlugin.ReadSector(0, out byte[] bootBlock);
+ imagePlugin.ReadSector(0, out byte[] bootBlock, out _);
metadata = new FileSystem
{
diff --git a/Aaru.Filesystems/ReFS/Info.cs b/Aaru.Filesystems/ReFS/Info.cs
index 33852d317..d224a5c1d 100644
--- a/Aaru.Filesystems/ReFS/Info.cs
+++ b/Aaru.Filesystems/ReFS/Info.cs
@@ -47,13 +47,13 @@ public sealed partial class ReFS
///
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
if(partition.Start + sbSize >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -73,13 +73,13 @@ public sealed partial class ReFS
information = "";
metadata = new FileSystem();
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
if(partition.Start + sbSize >= partition.End) return;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -87,21 +87,17 @@ public sealed partial class ReFS
VolumeHeader vhdr = Marshal.ByteArrayToStructureLittleEndian(sector);
- AaruLogging.Debug(MODULE_NAME,
- "VolumeHeader.jump empty? = {0}",
- ArrayHelpers.ArrayIsNullOrEmpty(vhdr.jump));
+ AaruLogging.Debug(MODULE_NAME, "VolumeHeader.jump empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(vhdr.jump));
+
+ AaruLogging.Debug(MODULE_NAME, "VolumeHeader.signature = {0}", StringHandlers.CToString(vhdr.signature));
AaruLogging.Debug(MODULE_NAME,
- "VolumeHeader.signature = {0}",
- StringHandlers.CToString(vhdr.signature));
+ "VolumeHeader.mustBeZero empty? = {0}",
+ ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero));
AaruLogging.Debug(MODULE_NAME,
- "VolumeHeader.mustBeZero empty? = {0}",
- ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero));
-
- AaruLogging.Debug(MODULE_NAME,
- "VolumeHeader.identifier = {0}",
- StringHandlers.CToString(BitConverter.GetBytes(vhdr.identifier)));
+ "VolumeHeader.identifier = {0}",
+ StringHandlers.CToString(BitConverter.GetBytes(vhdr.identifier)));
AaruLogging.Debug(MODULE_NAME, "VolumeHeader.length = {0}", vhdr.length);
AaruLogging.Debug(MODULE_NAME, "VolumeHeader.checksum = 0x{0:X4}", vhdr.checksum);
@@ -116,8 +112,8 @@ public sealed partial class ReFS
AaruLogging.Debug(MODULE_NAME, "VolumeHeader.unknown4 zero? = {0}", vhdr.unknown4 == 0);
AaruLogging.Debug(MODULE_NAME,
- "VolumeHeader.unknown5 empty? = {0}",
- ArrayHelpers.ArrayIsNullOrEmpty(vhdr.unknown5));
+ "VolumeHeader.unknown5 empty? = {0}",
+ ArrayHelpers.ArrayIsNullOrEmpty(vhdr.unknown5));
if(vhdr.identifier != FSRS ||
!ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero) ||
diff --git a/Aaru.Filesystems/Reiser/Info.cs b/Aaru.Filesystems/Reiser/Info.cs
index 0e3b7cfb1..e5d2a7577 100644
--- a/Aaru.Filesystems/Reiser/Info.cs
+++ b/Aaru.Filesystems/Reiser/Info.cs
@@ -57,7 +57,7 @@ public sealed partial class Reiser
if(partition.Start + sbAddr + sbSize >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -88,7 +88,7 @@ public sealed partial class Reiser
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/Reiser4/Info.cs b/Aaru.Filesystems/Reiser4/Info.cs
index a572652c4..89d8c8d84 100644
--- a/Aaru.Filesystems/Reiser4/Info.cs
+++ b/Aaru.Filesystems/Reiser4/Info.cs
@@ -57,7 +57,7 @@ public sealed partial class Reiser4
if(partition.Start + sbAddr + sbSize >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -86,7 +86,7 @@ public sealed partial class Reiser4
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/SFS/Info.cs b/Aaru.Filesystems/SFS/Info.cs
index e4a3efd01..522397816 100644
--- a/Aaru.Filesystems/SFS/Info.cs
+++ b/Aaru.Filesystems/SFS/Info.cs
@@ -46,7 +46,7 @@ public sealed partial class SFS
{
if(partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -61,7 +61,7 @@ public sealed partial class SFS
{
information = "";
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] rootBlockSector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] rootBlockSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/SolarFS/Info.cs b/Aaru.Filesystems/SolarFS/Info.cs
index e0d2bce68..f6dc3f09b 100644
--- a/Aaru.Filesystems/SolarFS/Info.cs
+++ b/Aaru.Filesystems/SolarFS/Info.cs
@@ -49,11 +49,11 @@ public sealed partial class SolarFS
{
if(2 + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpb);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpb, out _);
if(errno != ErrorNumber.NoError) return false;
- byte[] fsTypeB = new byte[8];
+ var fsTypeB = new byte[8];
byte signature = bpb[0x25];
Array.Copy(bpb, 0x35, fsTypeB, 0, 8);
@@ -71,7 +71,7 @@ public sealed partial class SolarFS
metadata = new FileSystem();
var sb = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpbSector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -87,7 +87,7 @@ public sealed partial class SolarFS
signature = bpbSector[0x25]
};
- byte[] bpbStrings = new byte[8];
+ var bpbStrings = new byte[8];
Array.Copy(bpbSector, 0x03, bpbStrings, 0, 8);
bpb.OEMName = StringHandlers.CToString(bpbStrings);
bpbStrings = new byte[8];
@@ -106,10 +106,10 @@ public sealed partial class SolarFS
bpb.unk4 = BitConverter.ToUInt32(bpbSector, 0x26);
AaruLogging.Debug(MODULE_NAME,
- "BPB.x86_jump: 0x{0:X2}{1:X2}{2:X2}",
- bpb.x86_jump[0],
- bpb.x86_jump[1],
- bpb.x86_jump[2]);
+ "BPB.x86_jump: 0x{0:X2}{1:X2}{2:X2}",
+ bpb.x86_jump[0],
+ bpb.x86_jump[1],
+ bpb.x86_jump[2]);
AaruLogging.Debug(MODULE_NAME, "BPB.OEMName: \"{0}\"", bpb.OEMName);
AaruLogging.Debug(MODULE_NAME, "BPB.bps: {0}", bpb.bps);
@@ -123,17 +123,17 @@ public sealed partial class SolarFS
AaruLogging.Debug(MODULE_NAME, "BPB.heads: {0}", bpb.heads);
AaruLogging.Debug(MODULE_NAME,
- "BPB.unk3: 0x{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}",
- bpb.unk3[0],
- bpb.unk3[1],
- bpb.unk3[2],
- bpb.unk3[3],
- bpb.unk3[4],
- bpb.unk3[5],
- bpb.unk3[6],
- bpb.unk3[7],
- bpb.unk3[8],
- bpb.unk3[9]);
+ "BPB.unk3: 0x{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}",
+ bpb.unk3[0],
+ bpb.unk3[1],
+ bpb.unk3[2],
+ bpb.unk3[3],
+ bpb.unk3[4],
+ bpb.unk3[5],
+ bpb.unk3[6],
+ bpb.unk3[7],
+ bpb.unk3[8],
+ bpb.unk3[9]);
AaruLogging.Debug(MODULE_NAME, "BPB.signature: 0x{0:X2}", bpb.signature);
AaruLogging.Debug(MODULE_NAME, "BPB.unk4: 0x{0:X8}", bpb.unk4);
diff --git a/Aaru.Filesystems/Squash/Info.cs b/Aaru.Filesystems/Squash/Info.cs
index 1b58d9ff4..ead7e9a20 100644
--- a/Aaru.Filesystems/Squash/Info.cs
+++ b/Aaru.Filesystems/Squash/Info.cs
@@ -47,7 +47,7 @@ public sealed partial class Squash
{
if(partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -62,7 +62,7 @@ public sealed partial class Squash
{
information = "";
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/SysV/Info.cs b/Aaru.Filesystems/SysV/Info.cs
index 6c7967047..9ab3af9b3 100644
--- a/Aaru.Filesystems/SysV/Info.cs
+++ b/Aaru.Filesystems/SysV/Info.cs
@@ -85,7 +85,7 @@ public sealed partial class SysVfs
imagePlugin.Info.Sectors))
{
ErrorNumber errno =
- imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out byte[] sb_sector);
+ imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out byte[] sb_sector, out _);
if(errno != ErrorNumber.NoError || sb_sector.Length < 0x400) continue;
@@ -186,7 +186,7 @@ public sealed partial class SysVfs
foreach(int i in locations)
{
- errno = imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out sb_sector);
+ errno = imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out sb_sector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -320,7 +320,7 @@ public sealed partial class SysVfs
{
var xenix_strings = new byte[6];
var xnx_sb = new XenixSuperBlock();
- errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector);
+ errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -490,7 +490,7 @@ public sealed partial class SysVfs
if(sysv)
{
- errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector);
+ errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -655,7 +655,7 @@ public sealed partial class SysVfs
if(coherent)
{
- errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector);
+ errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -728,7 +728,7 @@ public sealed partial class SysVfs
if(sys7th)
{
- errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector);
+ errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs
index a3523f3f3..41e83e094 100644
--- a/Aaru.Filesystems/UCSDPascal/File.cs
+++ b/Aaru.Filesystems/UCSDPascal/File.cs
@@ -39,6 +39,26 @@ namespace Aaru.Filesystems;
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public sealed partial class PascalPlugin
{
+ ErrorNumber GetFileEntry(string path, out PascalFileEntry entry)
+ {
+ entry = new PascalFileEntry();
+
+ foreach(PascalFileEntry ent in _fileEntries.Where(ent => string.Compare(path,
+ StringHandlers
+ .PascalToString(ent.Filename,
+ _encoding),
+ StringComparison
+ .InvariantCultureIgnoreCase) ==
+ 0))
+ {
+ entry = ent;
+
+ return ErrorNumber.NoError;
+ }
+
+ return ErrorNumber.NoSuchFile;
+ }
+
#region IReadOnlyFilesystem Members
///
@@ -94,7 +114,8 @@ public sealed partial class PascalPlugin
error = _device.ReadSectors((ulong)entry.FirstBlock * _multiplier,
(uint)(entry.LastBlock - entry.FirstBlock) * _multiplier,
- out byte[] tmp);
+ out byte[] tmp,
+ out _);
if(error != ErrorNumber.NoError) return error;
@@ -207,24 +228,4 @@ public sealed partial class PascalPlugin
}
#endregion
-
- ErrorNumber GetFileEntry(string path, out PascalFileEntry entry)
- {
- entry = new PascalFileEntry();
-
- foreach(PascalFileEntry ent in _fileEntries.Where(ent => string.Compare(path,
- StringHandlers
- .PascalToString(ent.Filename,
- _encoding),
- StringComparison
- .InvariantCultureIgnoreCase) ==
- 0))
- {
- entry = ent;
-
- return ErrorNumber.NoError;
- }
-
- return ErrorNumber.NoSuchFile;
- }
}
\ No newline at end of file
diff --git a/Aaru.Filesystems/UCSDPascal/Info.cs b/Aaru.Filesystems/UCSDPascal/Info.cs
index 27a6bda9b..b1440b25d 100644
--- a/Aaru.Filesystems/UCSDPascal/Info.cs
+++ b/Aaru.Filesystems/UCSDPascal/Info.cs
@@ -57,7 +57,7 @@ public sealed partial class PascalPlugin
// Blocks 0 and 1 are boot code
ErrorNumber errno =
- imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock);
+ imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -127,7 +127,7 @@ public sealed partial class PascalPlugin
// Blocks 0 and 1 are boot code
ErrorNumber errno =
- imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock);
+ imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock, out _);
if(errno != ErrorNumber.NoError) return;
@@ -189,7 +189,7 @@ public sealed partial class PascalPlugin
information = sbInformation.ToString();
- imagePlugin.ReadSectors(partition.Start, _multiplier * 2, out byte[] boot);
+ imagePlugin.ReadSectors(partition.Start, _multiplier * 2, out byte[] boot, out _);
metadata = new FileSystem
{
diff --git a/Aaru.Filesystems/UCSDPascal/Super.cs b/Aaru.Filesystems/UCSDPascal/Super.cs
index 137ab8387..a26c5858d 100644
--- a/Aaru.Filesystems/UCSDPascal/Super.cs
+++ b/Aaru.Filesystems/UCSDPascal/Super.cs
@@ -64,7 +64,7 @@ public sealed partial class PascalPlugin
_multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
// Blocks 0 and 1 are boot code
- ErrorNumber errno = _device.ReadSectors(_multiplier * 2, _multiplier, out _catalogBlocks);
+ ErrorNumber errno = _device.ReadSectors(_multiplier * 2, _multiplier, out _catalogBlocks, out _);
if(errno != ErrorNumber.NoError) return errno;
@@ -96,11 +96,12 @@ public sealed partial class PascalPlugin
errno = _device.ReadSectors(_multiplier * 2,
(uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * _multiplier,
- out _catalogBlocks);
+ out _catalogBlocks,
+ out _);
if(errno != ErrorNumber.NoError) return errno;
- int offset = 26;
+ var offset = 26;
_fileEntries = [];
@@ -123,7 +124,7 @@ public sealed partial class PascalPlugin
offset += 26;
}
- errno = _device.ReadSectors(0, 2 * _multiplier, out _bootBlocks);
+ errno = _device.ReadSectors(0, 2 * _multiplier, out _bootBlocks, out _);
if(errno != ErrorNumber.NoError) return errno;
diff --git a/Aaru.Filesystems/UDF/Info.cs b/Aaru.Filesystems/UDF/Info.cs
index 9ec2319ff..4d82b9663 100644
--- a/Aaru.Filesystems/UDF/Info.cs
+++ b/Aaru.Filesystems/UDF/Info.cs
@@ -65,7 +65,7 @@ public sealed partial class UDF
[partition.End - 1024, 4], [partition.End - 4, 4]
];
- bool anchorFound = false;
+ var anchorFound = false;
uint ratio = 1;
byte[] sector = null;
@@ -74,7 +74,8 @@ public sealed partial class UDF
position[0] + partition.Start + position[1] <=
partition.End &&
position[0] < partition.End)
- let errno = imagePlugin.ReadSectors(position[0], (uint)position[1], out sector)
+ let errno =
+ imagePlugin.ReadSectors(position[0], (uint)position[1], out sector, out _)
where errno == ErrorNumber.NoError
select position)
{
@@ -91,27 +92,25 @@ public sealed partial class UDF
AaruLogging.Debug(MODULE_NAME, "anchor.tag.descriptorCrc = 0x{0:X4}", anchor.tag.descriptorCrc);
- AaruLogging.Debug(MODULE_NAME,
- "anchor.tag.descriptorCrcLength = {0}",
- anchor.tag.descriptorCrcLength);
+ AaruLogging.Debug(MODULE_NAME, "anchor.tag.descriptorCrcLength = {0}", anchor.tag.descriptorCrcLength);
AaruLogging.Debug(MODULE_NAME, "anchor.tag.tagLocation = {0}", anchor.tag.tagLocation);
AaruLogging.Debug(MODULE_NAME,
- "anchor.mainVolumeDescriptorSequenceExtent.length = {0}",
- anchor.mainVolumeDescriptorSequenceExtent.length);
+ "anchor.mainVolumeDescriptorSequenceExtent.length = {0}",
+ anchor.mainVolumeDescriptorSequenceExtent.length);
AaruLogging.Debug(MODULE_NAME,
- "anchor.mainVolumeDescriptorSequenceExtent.location = {0}",
- anchor.mainVolumeDescriptorSequenceExtent.location);
+ "anchor.mainVolumeDescriptorSequenceExtent.location = {0}",
+ anchor.mainVolumeDescriptorSequenceExtent.location);
AaruLogging.Debug(MODULE_NAME,
- "anchor.reserveVolumeDescriptorSequenceExtent.length = {0}",
- anchor.reserveVolumeDescriptorSequenceExtent.length);
+ "anchor.reserveVolumeDescriptorSequenceExtent.length = {0}",
+ anchor.reserveVolumeDescriptorSequenceExtent.length);
AaruLogging.Debug(MODULE_NAME,
- "anchor.reserveVolumeDescriptorSequenceExtent.location = {0}",
- anchor.reserveVolumeDescriptorSequenceExtent.location);
+ "anchor.reserveVolumeDescriptorSequenceExtent.location = {0}",
+ anchor.reserveVolumeDescriptorSequenceExtent.location);
if(anchor.tag.tagIdentifier != TagIdentifier.AnchorVolumeDescriptorPointer ||
anchor.tag.tagLocation != position[0] / position[1] ||
@@ -135,7 +134,8 @@ public sealed partial class UDF
anchor.mainVolumeDescriptorSequenceExtent.location * ratio +
count * ratio,
ratio,
- out sector);
+ out sector,
+ out _);
if(errno != ErrorNumber.NoError)
{
@@ -144,8 +144,8 @@ public sealed partial class UDF
continue;
}
- var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0);
- uint location = BitConverter.ToUInt32(sector, 0x0C);
+ var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0);
+ var location = BitConverter.ToUInt32(sector, 0x0C);
if(location == partition.Start / ratio + anchor.mainVolumeDescriptorSequenceExtent.location + count)
{
@@ -197,7 +197,7 @@ public sealed partial class UDF
foreach(ulong[] position in positions)
{
- errno = imagePlugin.ReadSectors(position[0], (uint)position[1], out sector);
+ errno = imagePlugin.ReadSectors(position[0], (uint)position[1], out sector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -225,12 +225,13 @@ public sealed partial class UDF
anchor.mainVolumeDescriptorSequenceExtent.location * ratio +
count * ratio,
ratio,
- out sector);
+ out sector,
+ out _);
if(errno != ErrorNumber.NoError) continue;
- var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0);
- uint location = BitConverter.ToUInt32(sector, 0x0C);
+ var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0);
+ var location = BitConverter.ToUInt32(sector, 0x0C);
if(location == partition.Start / ratio + anchor.mainVolumeDescriptorSequenceExtent.location + count)
{
@@ -254,7 +255,7 @@ public sealed partial class UDF
count++;
}
- errno = imagePlugin.ReadSectors(lvd.integritySequenceExtent.location * ratio, ratio, out sector);
+ errno = imagePlugin.ReadSectors(lvd.integritySequenceExtent.location * ratio, ratio, out sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/UNICOS/Info.cs b/Aaru.Filesystems/UNICOS/Info.cs
index 5672263dc..21f87c135 100644
--- a/Aaru.Filesystems/UNICOS/Info.cs
+++ b/Aaru.Filesystems/UNICOS/Info.cs
@@ -49,13 +49,13 @@ public sealed partial class UNICOS
{
if(imagePlugin.Info.SectorSize < 512) return false;
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
if(partition.Start + sbSize >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -78,11 +78,11 @@ public sealed partial class UNICOS
if(imagePlugin.Info.SectorSize < 512) return;
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/UNIXBFS/Info.cs b/Aaru.Filesystems/UNIXBFS/Info.cs
index 4f9571bf5..aedc2b1be 100644
--- a/Aaru.Filesystems/UNIXBFS/Info.cs
+++ b/Aaru.Filesystems/UNIXBFS/Info.cs
@@ -49,11 +49,11 @@ public sealed partial class BFS
{
if(2 + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] tmp);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] tmp, out _);
if(errno != ErrorNumber.NoError) return false;
- uint magic = BitConverter.ToUInt32(tmp, 0);
+ var magic = BitConverter.ToUInt32(tmp, 0);
return magic == BFS_MAGIC;
}
@@ -67,11 +67,11 @@ public sealed partial class BFS
metadata = new FileSystem();
var sb = new StringBuilder();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bfsSbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bfsSbSector, out _);
if(errno != ErrorNumber.NoError) return;
- byte[] sbStrings = new byte[6];
+ var sbStrings = new byte[6];
var bfsSb = new SuperBlock
{
diff --git a/Aaru.Filesystems/VMfs/Info.cs b/Aaru.Filesystems/VMfs/Info.cs
index 0cf55480e..0bf91cab3 100644
--- a/Aaru.Filesystems/VMfs/Info.cs
+++ b/Aaru.Filesystems/VMfs/Info.cs
@@ -57,7 +57,7 @@ public sealed partial class VMfs
if(partition.Start + vmfsSuperOff > partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -74,7 +74,7 @@ public sealed partial class VMfs
information = "";
metadata = new FileSystem();
ulong vmfsSuperOff = VMFS_BASE / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/VxFS/Info.cs b/Aaru.Filesystems/VxFS/Info.cs
index 2eb29d259..c34f68f64 100644
--- a/Aaru.Filesystems/VxFS/Info.cs
+++ b/Aaru.Filesystems/VxFS/Info.cs
@@ -49,7 +49,7 @@ public sealed partial class VxFS
if(partition.Start + vmfsSuperOff >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -66,7 +66,7 @@ public sealed partial class VxFS
information = "";
metadata = new FileSystem();
ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;
- ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/XFS/Info.cs b/Aaru.Filesystems/XFS/Info.cs
index 55a752dd5..731ccd5e9 100644
--- a/Aaru.Filesystems/XFS/Info.cs
+++ b/Aaru.Filesystems/XFS/Info.cs
@@ -51,17 +51,17 @@ public sealed partial class XFS
// Misaligned
if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc)
{
- uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize);
if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
if(sector.Length < Marshal.SizeOf()) return false;
- byte[] sbpiece = new byte[Marshal.SizeOf()];
+ var sbpiece = new byte[Marshal.SizeOf()];
foreach(int location in new[]
{
@@ -73,10 +73,10 @@ public sealed partial class XFS
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_X3_equals_1_expected_2,
- location,
- xfsSb.magicnum,
- XFS_MAGIC);
+ Localization.magic_at_0_X3_equals_1_expected_2,
+ location,
+ xfsSb.magicnum,
+ XFS_MAGIC);
if(xfsSb.magicnum == XFS_MAGIC) return true;
}
@@ -88,13 +88,14 @@ public sealed partial class XFS
0, 1, 2
})
{
- ulong location = (ulong)i;
+ var location = (ulong)i;
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector);
+ ErrorNumber errno =
+ imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) continue;
@@ -103,10 +104,10 @@ public sealed partial class XFS
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_expected_2,
- location,
- xfsSb.magicnum,
- XFS_MAGIC);
+ Localization.magic_at_0_equals_1_expected_2,
+ location,
+ xfsSb.magicnum,
+ XFS_MAGIC);
if(xfsSb.magicnum == XFS_MAGIC) return true;
}
@@ -130,15 +131,15 @@ public sealed partial class XFS
// Misaligned
if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc)
{
- uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize);
+ var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize);
if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return;
- byte[] sbpiece = new byte[Marshal.SizeOf()];
+ var sbpiece = new byte[Marshal.SizeOf()];
foreach(int location in new[]
{
@@ -150,10 +151,10 @@ public sealed partial class XFS
xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_X3_equals_1_expected_2,
- location,
- xfsSb.magicnum,
- XFS_MAGIC);
+ Localization.magic_at_0_X3_equals_1_expected_2,
+ location,
+ xfsSb.magicnum,
+ XFS_MAGIC);
if(xfsSb.magicnum == XFS_MAGIC) break;
}
@@ -165,22 +166,23 @@ public sealed partial class XFS
0, 1, 2
})
{
- ulong location = (ulong)i;
- uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
+ var location = (ulong)i;
+ var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector);
+ ErrorNumber errno =
+ imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return;
xfsSb = Marshal.ByteArrayToStructureBigEndian(sector);
AaruLogging.Debug(MODULE_NAME,
- Localization.magic_at_0_equals_1_expected_2,
- location,
- xfsSb.magicnum,
- XFS_MAGIC);
+ Localization.magic_at_0_equals_1_expected_2,
+ location,
+ xfsSb.magicnum,
+ XFS_MAGIC);
if(xfsSb.magicnum == XFS_MAGIC) break;
}
diff --git a/Aaru.Filesystems/Xia/Info.cs b/Aaru.Filesystems/Xia/Info.cs
index ac32f1d08..df39eb6f5 100644
--- a/Aaru.Filesystems/Xia/Info.cs
+++ b/Aaru.Filesystems/Xia/Info.cs
@@ -57,7 +57,7 @@ public sealed partial class Xia
if(sbSizeInSectors + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -80,7 +80,7 @@ public sealed partial class Xia
if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/ZFS/Info.cs b/Aaru.Filesystems/ZFS/Info.cs
index 351a773f2..7e1e939a2 100644
--- a/Aaru.Filesystems/ZFS/Info.cs
+++ b/Aaru.Filesystems/ZFS/Info.cs
@@ -77,7 +77,7 @@ public sealed partial class ZFS
if(partition.Start + 31 < partition.End)
{
- errno = imagePlugin.ReadSector(partition.Start + 31, out sector);
+ errno = imagePlugin.ReadSector(partition.Start + 31, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -88,7 +88,7 @@ public sealed partial class ZFS
if(partition.Start + 16 >= partition.End) return false;
- errno = imagePlugin.ReadSector(partition.Start + 16, out sector);
+ errno = imagePlugin.ReadSector(partition.Start + 16, out sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -116,7 +116,7 @@ public sealed partial class ZFS
if(partition.Start + 31 < partition.End)
{
- errno = imagePlugin.ReadSector(partition.Start + 31, out sector);
+ errno = imagePlugin.ReadSector(partition.Start + 31, out sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -127,7 +127,7 @@ public sealed partial class ZFS
if(partition.Start + 16 < partition.End)
{
- errno = imagePlugin.ReadSector(partition.Start + 16, out sector);
+ errno = imagePlugin.ReadSector(partition.Start + 16, out sector, out _);
if(errno != ErrorNumber.NoError) return;
@@ -139,7 +139,7 @@ public sealed partial class ZFS
var sb = new StringBuilder();
sb.AppendLine(Localization.ZFS_filesystem);
- errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, nvlistLen, out byte[] nvlist);
+ errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, nvlistLen, out byte[] nvlist, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/dump/Info.cs b/Aaru.Filesystems/dump/Info.cs
index 54a728d0a..782d0bd25 100644
--- a/Aaru.Filesystems/dump/Info.cs
+++ b/Aaru.Filesystems/dump/Info.cs
@@ -61,7 +61,7 @@ public sealed partial class Dump
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -100,7 +100,7 @@ public sealed partial class Dump
if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++;
- ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector);
+ ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/exFAT/Info.cs b/Aaru.Filesystems/exFAT/Info.cs
index c8b330c8e..4c0d92907 100644
--- a/Aaru.Filesystems/exFAT/Info.cs
+++ b/Aaru.Filesystems/exFAT/Info.cs
@@ -53,7 +53,7 @@ public sealed partial class exFAT
{
if(12 + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -73,20 +73,20 @@ public sealed partial class exFAT
var sb = new StringBuilder();
metadata = new FileSystem();
- ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector);
+ ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector, out _);
if(errno != ErrorNumber.NoError) return;
VolumeBootRecord vbr = Marshal.ByteArrayToStructureLittleEndian(vbrSector);
- errno = imagePlugin.ReadSector(9 + partition.Start, out byte[] parametersSector);
+ errno = imagePlugin.ReadSector(9 + partition.Start, out byte[] parametersSector, out _);
if(errno != ErrorNumber.NoError) return;
OemParameterTable parametersTable =
Marshal.ByteArrayToStructureLittleEndian(parametersSector);
- errno = imagePlugin.ReadSector(11 + partition.Start, out byte[] chkSector);
+ errno = imagePlugin.ReadSector(11 + partition.Start, out byte[] chkSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/ext2FS/Info.cs b/Aaru.Filesystems/ext2FS/Info.cs
index 68091d6d0..5fc03afc1 100644
--- a/Aaru.Filesystems/ext2FS/Info.cs
+++ b/Aaru.Filesystems/ext2FS/Info.cs
@@ -65,7 +65,7 @@ public sealed partial class ext2FS
if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++;
ErrorNumber errno =
- imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector);
+ imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -103,7 +103,7 @@ public sealed partial class ext2FS
uint sbOff = SB_POS % imagePlugin.Info.SectorSize;
ErrorNumber errno =
- imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector);
+ imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Filesystems/extFS/Info.cs b/Aaru.Filesystems/extFS/Info.cs
index 8780d7976..0c3d02106 100644
--- a/Aaru.Filesystems/extFS/Info.cs
+++ b/Aaru.Filesystems/extFS/Info.cs
@@ -54,7 +54,7 @@ public sealed partial class extFS
if(sbSectorOff + partition.Start >= partition.End) return false;
- ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sbSector);
+ ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sbSector, out _);
if(errno != ErrorNumber.NoError) return false;
@@ -85,7 +85,7 @@ public sealed partial class extFS
if(sbSectorOff + partition.Start >= partition.End) return;
- ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sblock);
+ ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sblock, out _);
if(errno != ErrorNumber.NoError) return;
diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs
index b0758ce03..353f6115b 100644
--- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs
+++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs
@@ -224,8 +224,8 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork()
{
- var opticalMediaImage = _inputFormat as IOpticalMediaImage;
- bool formatHasTracks = false;
+ var opticalMediaImage = _inputFormat as IOpticalMediaImage;
+ var formatHasTracks = false;
if(opticalMediaImage != null)
{
@@ -321,7 +321,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
Progress2Text = $"Hashing track-less sector {sector}";
});
- errno = opticalMediaImage.ReadSector(i, out byte[] hiddenSector);
+ errno = opticalMediaImage.ReadSector(i, out byte[] hiddenSector, out _);
if(errno != ErrorNumber.NoError)
{
@@ -368,7 +368,8 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
errno = opticalMediaImage.ReadSectors(doneSectors,
SECTORS_TO_READ,
currentTrack.Sequence,
- out sector);
+ out sector,
+ out _);
if(errno != ErrorNumber.NoError)
{
@@ -398,7 +399,8 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
errno = opticalMediaImage.ReadSectors(doneSectors,
(uint)(sectors - doneSectors),
currentTrack.Sequence,
- out sector);
+ out sector,
+ out _);
if(errno != ErrorNumber.NoError)
{
@@ -462,7 +464,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
Progress2Text = $"Hashing track-less sector {sector}";
});
- errno = opticalMediaImage.ReadSector(i, out byte[] hiddenSector);
+ errno = opticalMediaImage.ReadSector(i, out byte[] hiddenSector, out _);
if(errno != ErrorNumber.NoError)
{
@@ -524,7 +526,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
if(_inputFormat.Info.Sectors - doneSectors >= SECTORS_TO_READ)
{
- errno = _inputFormat.ReadSectors(doneSectors, SECTORS_TO_READ, out sector);
+ errno = _inputFormat.ReadSectors(doneSectors, SECTORS_TO_READ, out sector, out _);
if(errno != ErrorNumber.NoError)
{
@@ -554,7 +556,8 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase
{
errno = _inputFormat.ReadSectors(doneSectors,
(uint)(_inputFormat.Info.Sectors - doneSectors),
- out sector);
+ out sector,
+ out _);
if(errno != ErrorNumber.NoError)
{
diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs
index 0f36d5252..9a542cbcb 100644
--- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs
+++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs
@@ -746,8 +746,8 @@ public sealed partial class ImageConvertViewModel : ViewModelBase
if(useLong)
{
errno = sectorsToDo == 1
- ? _inputFormat.ReadSectorLong(doneSectors, out sector)
- : _inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector);
+ ? _inputFormat.ReadSectorLong(doneSectors, out sector, out _)
+ : _inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector, out _);
if(errno == ErrorNumber.NoError)
{
@@ -786,8 +786,8 @@ public sealed partial class ImageConvertViewModel : ViewModelBase
else
{
errno = sectorsToDo == 1
- ? _inputFormat.ReadSector(doneSectors, out sector)
- : _inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector);
+ ? _inputFormat.ReadSector(doneSectors, out sector, out _)
+ : _inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector, out _);
if(errno == ErrorNumber.NoError)
{
@@ -1205,10 +1205,11 @@ public sealed partial class ImageConvertViewModel : ViewModelBase
if(useLong)
{
errno = sectorsToDo == 1
- ? _inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector)
+ ? _inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector, out _)
: _inputFormat.ReadSectorsLong(doneSectors + track.StartSector,
sectorsToDo,
- out sector);
+ out sector,
+ out _);
if(errno == ErrorNumber.NoError)
{
@@ -1247,10 +1248,11 @@ public sealed partial class ImageConvertViewModel : ViewModelBase
else
{
errno = sectorsToDo == 1
- ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector)
+ ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector, out _)
: _inputFormat.ReadSectors(doneSectors + track.StartSector,
sectorsToDo,
- out sector);
+ out sector,
+ out _);
if(errno == ErrorNumber.NoError)
{
diff --git a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs
index f9080e724..c583e5f6c 100644
--- a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs
+++ b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs
@@ -55,11 +55,12 @@ public sealed partial class ViewSectorViewModel : ViewModelBase
[ObservableProperty]
string _totalSectorsText;
+ // TODO: Show message when sector was not dumped
public ViewSectorViewModel([NotNull] IMediaImage inputFormat)
{
_inputFormat = inputFormat;
- ErrorNumber errno = inputFormat.ReadSectorLong(0, out _);
+ ErrorNumber errno = inputFormat.ReadSectorLong(0, out _, out _);
if(errno == ErrorNumber.NoError)
LongSectorChecked = true;
@@ -82,8 +83,8 @@ public sealed partial class ViewSectorViewModel : ViewModelBase
SetProperty(ref _sectorNumber, value);
ErrorNumber errno = LongSectorChecked
- ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out byte[] sector)
- : _inputFormat.ReadSector((ulong)SectorNumber, out sector);
+ ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out byte[] sector, out _)
+ : _inputFormat.ReadSector((ulong)SectorNumber, out sector, out _);
if(errno == ErrorNumber.NoError) PrintHexText = PrintHex.ByteArrayToHexArrayString(sector, HEX_COLUMNS);
}
diff --git a/Aaru.Images/A2R/Read.cs b/Aaru.Images/A2R/Read.cs
index 229daaf9a..0d5dc171a 100644
--- a/Aaru.Images/A2R/Read.cs
+++ b/Aaru.Images/A2R/Read.cs
@@ -57,25 +57,23 @@ public sealed partial class A2R
_a2RFilter = imageFilter;
- byte[] hdr = new byte[Marshal.SizeOf()];
+ var hdr = new byte[Marshal.SizeOf()];
_a2RStream.EnsureRead(hdr, 0, Marshal.SizeOf());
_header = Marshal.ByteArrayToStructureLittleEndian(hdr);
- AaruLogging.Debug(MODULE_NAME,
- "header.signature = \"{0}\"",
- StringHandlers.CToString(_header.signature));
+ AaruLogging.Debug(MODULE_NAME, "header.signature = \"{0}\"", StringHandlers.CToString(_header.signature));
AaruLogging.Debug(MODULE_NAME, "header.version = {0}", _header.version);
AaruLogging.Debug(MODULE_NAME, "header.highBitTest = {0:X2}", _header.highBitTest);
AaruLogging.Debug(MODULE_NAME,
- "header.lineTest = {0:X2} {1:X2} {2:X2}",
- _header.lineTest[0],
- _header.lineTest[1],
- _header.lineTest[2]);
+ "header.lineTest = {0:X2} {1:X2} {2:X2}",
+ _header.lineTest[0],
+ _header.lineTest[1],
+ _header.lineTest[2]);
- byte[] infoMagic = new byte[4];
+ var infoMagic = new byte[4];
_a2RStream.EnsureRead(infoMagic, 0, 4);
// There must be an INFO chunk after the header (at byte 16)
@@ -87,23 +85,21 @@ public sealed partial class A2R
{
case 0x32:
{
- byte[] infoChnk = new byte[Marshal.SizeOf()];
+ var infoChnk = new byte[Marshal.SizeOf()];
_a2RStream.EnsureRead(infoChnk, 0, Marshal.SizeOf());
_infoChunkV2 = Marshal.ByteArrayToStructureLittleEndian(infoChnk);
AaruLogging.Debug(MODULE_NAME,
- "infoChunk.header.chunkId = \"{0}\"",
- StringHandlers.CToString(_infoChunkV2.header.chunkId));
+ "infoChunk.header.chunkId = \"{0}\"",
+ StringHandlers.CToString(_infoChunkV2.header.chunkId));
- AaruLogging.Debug(MODULE_NAME,
- "infoChunk.header.chunkSize = {0}",
- _infoChunkV2.header.chunkSize);
+ AaruLogging.Debug(MODULE_NAME, "infoChunk.header.chunkSize = {0}", _infoChunkV2.header.chunkSize);
AaruLogging.Debug(MODULE_NAME, "infoChunk.version = {0}", _infoChunkV2.version);
AaruLogging.Debug(MODULE_NAME,
- "infoChunk.creator = \"{0}\"",
- StringHandlers.CToString(_infoChunkV2.creator).TrimEnd());
+ "infoChunk.creator = \"{0}\"",
+ StringHandlers.CToString(_infoChunkV2.creator).TrimEnd());
AaruLogging.Debug(MODULE_NAME, "infoChunk.diskType = {0}", _infoChunkV2.diskType);
@@ -136,23 +132,21 @@ public sealed partial class A2R
}
case 0x33:
{
- byte[] infoChk = new byte[Marshal.SizeOf()];
+ var infoChk = new byte[Marshal.SizeOf()];
_a2RStream.EnsureRead(infoChk, 0, Marshal.SizeOf());
_infoChunkV3 = Marshal.ByteArrayToStructureLittleEndian(infoChk);
AaruLogging.Debug(MODULE_NAME,
- "infoChunk.header.chunkId = \"{0}\"",
- StringHandlers.CToString(_infoChunkV3.header.chunkId));
+ "infoChunk.header.chunkId = \"{0}\"",
+ StringHandlers.CToString(_infoChunkV3.header.chunkId));
- AaruLogging.Debug(MODULE_NAME,
- "infoChunk.header.chunkSize = {0}",
- _infoChunkV3.header.chunkSize);
+ AaruLogging.Debug(MODULE_NAME, "infoChunk.header.chunkSize = {0}", _infoChunkV3.header.chunkSize);
AaruLogging.Debug(MODULE_NAME, "infoChunk.version = {0}", _infoChunkV3.version);
AaruLogging.Debug(MODULE_NAME,
- "infoChunk.creator = \"{0}\"",
- StringHandlers.CToString(_infoChunkV3.creator).TrimEnd());
+ "infoChunk.creator = \"{0}\"",
+ StringHandlers.CToString(_infoChunkV3.creator).TrimEnd());
AaruLogging.Debug(MODULE_NAME, "infoChunk.driveType = {0}", _infoChunkV3.driveType);
@@ -160,9 +154,7 @@ public sealed partial class A2R
AaruLogging.Debug(MODULE_NAME, "infoChunk.synchronized = {0}", _infoChunkV3.synchronized);
- AaruLogging.Debug(MODULE_NAME,
- "infoChunk.hardSectorCount = {0}",
- _infoChunkV3.hardSectorCount);
+ AaruLogging.Debug(MODULE_NAME, "infoChunk.hardSectorCount = {0}", _infoChunkV3.hardSectorCount);
_imageInfo.Creator = Encoding.ASCII.GetString(_infoChunkV3.creator).TrimEnd();
@@ -228,7 +220,7 @@ public sealed partial class A2R
while(_a2RStream.Position < _a2RStream.Length)
{
- byte[] chunkHdr = new byte[Marshal.SizeOf()];
+ var chunkHdr = new byte[Marshal.SizeOf()];
_a2RStream.EnsureRead(chunkHdr, 0, Marshal.SizeOf());
ChunkHeader chunkHeader = Marshal.ByteArrayToStructureLittleEndian(chunkHdr);
_a2RStream.Seek(-Marshal.SizeOf(), SeekOrigin.Current);
@@ -236,7 +228,7 @@ public sealed partial class A2R
switch(chunkHeader.chunkId)
{
case var rwcp when rwcp.SequenceEqual(_rwcpChunkSignature):
- byte[] rwcpBuffer = new byte[Marshal.SizeOf()];
+ var rwcpBuffer = new byte[Marshal.SizeOf()];
_a2RStream.EnsureRead(rwcpBuffer, 0, Marshal.SizeOf());
RwcpChunkHeader rwcpChunk = Marshal.ByteArrayToStructureLittleEndian(rwcpBuffer);
@@ -248,7 +240,7 @@ public sealed partial class A2R
captureType = (byte)_a2RStream.ReadByte()
};
- byte[] location = new byte[2];
+ var location = new byte[2];
_a2RStream.EnsureRead(location, 0, 2);
capture.location = BitConverter.ToUInt16(location);
@@ -265,14 +257,14 @@ public sealed partial class A2R
capture.numberOfIndexSignals = (byte)_a2RStream.ReadByte();
capture.indexSignals = new uint[capture.numberOfIndexSignals];
- for(int i = 0; capture.numberOfIndexSignals > i; i++)
+ for(var i = 0; capture.numberOfIndexSignals > i; i++)
{
- byte[] index = new byte[4];
+ var index = new byte[4];
_a2RStream.EnsureRead(index, 0, 4);
capture.indexSignals[i] = BitConverter.ToUInt32(index);
}
- byte[] dataSize = new byte[4];
+ var dataSize = new byte[4];
_a2RStream.EnsureRead(dataSize, 0, 4);
capture.captureDataSize = BitConverter.ToUInt32(dataSize);
@@ -291,7 +283,7 @@ public sealed partial class A2R
_a2RStream.Seek(Marshal.SizeOf(), SeekOrigin.Current);
- byte[] metadataBuffer = new byte[chunkHeader.chunkSize];
+ var metadataBuffer = new byte[chunkHeader.chunkSize];
_a2RStream.EnsureRead(metadataBuffer, 0, (int)chunkHeader.chunkSize);
string metaData = Encoding.UTF8.GetString(metadataBuffer);
@@ -311,7 +303,7 @@ public sealed partial class A2R
case var slvd when slvd.SequenceEqual(_slvdChunkSignature):
return ErrorNumber.NotImplemented;
case var strm when strm.SequenceEqual(_strmChunkSignature):
- byte[] strmBuffer = new byte[Marshal.SizeOf()];
+ var strmBuffer = new byte[Marshal.SizeOf()];
_a2RStream.EnsureRead(strmBuffer, 0, Marshal.SizeOf());
ChunkHeader strmChunk = Marshal.ByteArrayToStructureLittleEndian(strmBuffer);
@@ -338,11 +330,11 @@ public sealed partial class A2R
if(capture.track + 1 > _imageInfo.Cylinders) _imageInfo.Cylinders = (uint)(capture.track + 1);
- byte[] dataSize = new byte[4];
+ var dataSize = new byte[4];
_a2RStream.EnsureRead(dataSize, 0, 4);
capture.captureDataSize = BitConverter.ToUInt32(dataSize);
- byte[] index = new byte[4];
+ var index = new byte[4];
_a2RStream.EnsureRead(index, 0, 4);
capture.indexSignals[0] = BitConverter.ToUInt32(index);
@@ -432,7 +424,7 @@ public sealed partial class A2R
uint previousTicks = 0;
- for(int i = 0; i < capture.numberOfIndexSignals; i++)
+ for(var i = 0; i < capture.numberOfIndexSignals; i++)
{
uint ticks = capture.indexSignals[i] - previousTicks;
tmpBuffer.AddRange(UInt32ToFluxRepresentation(ticks));
@@ -481,19 +473,22 @@ public sealed partial class A2R
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer) => throw new NotImplementedException();
///
- public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => throw new NotImplementedException();
-
- ///
- public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) => throw new NotImplementedException();
-
- ///
- public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) =>
+ public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) =>
throw new NotImplementedException();
///
- public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer) =>
+ public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) =>
throw new NotImplementedException();
+ ///
+ public ErrorNumber
+ ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) =>
+ throw new NotImplementedException();
+
+ ///
+ public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer,
+ out SectorStatus[] sectorStatus) => throw new NotImplementedException();
+
///
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) =>
throw new NotImplementedException();
diff --git a/Aaru.Images/AaruFormat/Optical.cs b/Aaru.Images/AaruFormat/Optical.cs
index f188022f0..3a11e88d1 100644
--- a/Aaru.Images/AaruFormat/Optical.cs
+++ b/Aaru.Images/AaruFormat/Optical.cs
@@ -144,10 +144,10 @@ public sealed partial class AaruFormat
foreach(Track trk in tracks)
{
- ReadSector(trk.StartSector, out byte[] sector);
+ ReadSector(trk.StartSector, out byte[] sector, out _);
trk.BytesPerSector = sector?.Length ?? (trk.Type == TrackType.Audio ? 2352 : 2048);
- ErrorNumber errno = ReadSectorLong(trk.StartSector, out byte[] longSector);
+ ErrorNumber errno = ReadSectorLong(trk.StartSector, out byte[] longSector, out _);
if(errno == ErrorNumber.NoError)
trk.RawBytesPerSector = longSector.Length;
diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs
index 56a16152d..a2be79d93 100644
--- a/Aaru.Images/AaruFormat/Read.cs
+++ b/Aaru.Images/AaruFormat/Read.cs
@@ -69,19 +69,21 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer)
+ public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus)
{
buffer = null;
uint length = 0;
+ sectorStatus = SectorStatus.NotDumped;
- // TODO: Sector status API
Status res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out _);
if(res != Status.BufferTooSmall) return StatusToErrorNumber(res);
buffer = new byte[length];
- res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out _);
+ res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out byte libSectorStatus);
+
+ sectorStatus = (SectorStatus)libSectorStatus;
// Sector not dumped
if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
@@ -92,10 +94,11 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer)
+ public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus)
{
buffer = null;
uint length = 0;
+ sectorStatus = SectorStatus.NotDumped;
Status res = aaruf_read_track_sector(_context, buffer, sectorAddress, ref length, (byte)track, out _);
@@ -103,7 +106,14 @@ public sealed partial class AaruFormat
buffer = new byte[length];
- res = aaruf_read_track_sector(_context, buffer, sectorAddress, ref length, (byte)track, out _);
+ res = aaruf_read_track_sector(_context,
+ buffer,
+ sectorAddress,
+ ref length,
+ (byte)track,
+ out byte libSectorStatus);
+
+ sectorStatus = (SectorStatus)libSectorStatus;
// Sector not dumped
if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
@@ -114,10 +124,11 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)
+ public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus)
{
buffer = null;
uint length = 0;
+ sectorStatus = SectorStatus.NotDumped;
Status res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _);
@@ -125,7 +136,9 @@ public sealed partial class AaruFormat
buffer = new byte[length];
- res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _);
+ res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out byte libSectorStatus);
+
+ sectorStatus = (SectorStatus)libSectorStatus;
// Sector not dumped
if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
@@ -186,17 +199,21 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
+ public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus)
{
MemoryStream ms = new();
+ sectorStatus = new SectorStatus[length];
for(uint i = 0; i < length; i++)
{
- ErrorNumber res = ReadSector(sectorAddress + i, out byte[] sectorBuffer);
+ ErrorNumber res = ReadSector(sectorAddress + i,
+ out byte[] sectorBuffer,
+ out SectorStatus singleSectorStatus);
if(res != ErrorNumber.NoError)
{
- buffer = ms.ToArray();
+ buffer = ms.ToArray();
+ sectorStatus[i] = singleSectorStatus;
return res;
}
@@ -210,17 +227,22 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer)
+ public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer,
+ out SectorStatus[] sectorStatus)
{
MemoryStream ms = new();
+ sectorStatus = new SectorStatus[length];
for(uint i = 0; i < length; i++)
{
- ErrorNumber res = ReadSectorLong(sectorAddress + i, out byte[] sectorBuffer);
+ ErrorNumber res = ReadSectorLong(sectorAddress + i,
+ out byte[] sectorBuffer,
+ out SectorStatus singleSectorStatus);
if(res != ErrorNumber.NoError)
{
- buffer = ms.ToArray();
+ buffer = ms.ToArray();
+ sectorStatus[i] = singleSectorStatus;
return res;
}
@@ -274,9 +296,11 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer)
+ public ErrorNumber ReadSectors(ulong sectorAddress, uint length, uint track, out byte[] buffer,
+ out SectorStatus[] sectorStatus)
{
- buffer = null;
+ buffer = null;
+ sectorStatus = null;
if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported;
@@ -288,7 +312,7 @@ public sealed partial class AaruFormat
return trk.StartSector + sectorAddress + length > trk.EndSector + 1
? ErrorNumber.OutOfRange
- : ReadSectors(trk.StartSector + sectorAddress, length, out buffer);
+ : ReadSectors(trk.StartSector + sectorAddress, length, out buffer, out sectorStatus);
}
///
@@ -311,9 +335,10 @@ public sealed partial class AaruFormat
}
///
- public ErrorNumber ReadSectorLong(ulong sectorAddress, uint track, out byte[] buffer)
+ public ErrorNumber ReadSectorLong(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus)
{
- buffer = null;
+ buffer = null;
+ sectorStatus = SectorStatus.NotDumped;
if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported;
@@ -323,13 +348,15 @@ public sealed partial class AaruFormat
return trk?.Sequence != track
? ErrorNumber.SectorNotFound
- : ReadSectorLong(trk.StartSector + sectorAddress, out buffer);
+ : ReadSectorLong(trk.StartSector + sectorAddress, out buffer, out sectorStatus);
}
///
- public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer)
+ public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, uint track, out byte[] buffer,
+ out SectorStatus[] sectorStatus)
{
- buffer = null;
+ buffer = null;
+ sectorStatus = null;
if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported;
@@ -341,7 +368,7 @@ public sealed partial class AaruFormat
? ErrorNumber.SectorNotFound
: trk.StartSector + sectorAddress + length > trk.EndSector + 1
? ErrorNumber.OutOfRange
- : ReadSectorsLong(trk.StartSector + sectorAddress, length, out buffer);
+ : ReadSectorsLong(trk.StartSector + sectorAddress, length, out buffer, out sectorStatus);
}
#endregion
diff --git a/Aaru.Images/AaruFormat/Verify.cs b/Aaru.Images/AaruFormat/Verify.cs
index 410c4033c..fbb7deef1 100644
--- a/Aaru.Images/AaruFormat/Verify.cs
+++ b/Aaru.Images/AaruFormat/Verify.cs
@@ -23,6 +23,11 @@ public sealed partial class AaruFormat
#endregion
+ // AARU_EXPORT int32_t AARU_CALL aaruf_verify_image(void *context)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_verify_image", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_verify_image(IntPtr context);
+
#region IWritableOpticalImage Members
///
@@ -30,7 +35,7 @@ public sealed partial class AaruFormat
{
if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return null;
- ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer);
+ ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _);
return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer);
}
@@ -50,7 +55,7 @@ public sealed partial class AaruFormat
return null;
}
- ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer);
+ ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _);
if(errno != ErrorNumber.NoError) return null;
@@ -81,7 +86,8 @@ public sealed partial class AaruFormat
return failingLbas.Count <= 0;
}
- ///
+
+ ///
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List failingLbas,
out List unknownLbas)
{
@@ -99,7 +105,7 @@ public sealed partial class AaruFormat
failingLbas = [];
unknownLbas = [];
- ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer);
+ ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer, out _);
if(errno != ErrorNumber.NoError) return null;
@@ -130,9 +136,4 @@ public sealed partial class AaruFormat
}
#endregion
-
- // AARU_EXPORT int32_t AARU_CALL aaruf_verify_image(void *context)
- [LibraryImport("libaaruformat", EntryPoint = "aaruf_verify_image", SetLastError = true)]
- [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
- private static partial Status aaruf_verify_image(IntPtr context);
}
\ No newline at end of file
diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs
index 3bfc20886..269389c0e 100644
--- a/Aaru.Images/Alcohol120/Read.cs
+++ b/Aaru.Images/Alcohol120/Read.cs
@@ -59,7 +59,7 @@ public sealed partial class Alcohol120
if(stream.Length < 88) return ErrorNumber.InvalidArgument;
_isDvd = false;
- byte[] hdr = new byte[88];
+ var hdr = new byte[88];
stream.EnsureRead(hdr, 0, 88);
_header = Marshal.ByteArrayToStructureLittleEndian(hdr);
@@ -70,22 +70,22 @@ public sealed partial class Alcohol120
AaruLogging.Debug(MODULE_NAME, "header.type = {0}", _header.type);
AaruLogging.Debug(MODULE_NAME, "header.sessions = {0}", _header.sessions);
- for(int i = 0; i < _header.unknown1.Length; i++)
+ for(var i = 0; i < _header.unknown1.Length; i++)
AaruLogging.Debug(MODULE_NAME, "header.unknown1[{1}] = 0x{0:X4}", _header.unknown1[i], i);
AaruLogging.Debug(MODULE_NAME, "header.bcaLength = {0}", _header.bcaLength);
- for(int i = 0; i < _header.unknown2.Length; i++)
+ for(var i = 0; i < _header.unknown2.Length; i++)
AaruLogging.Debug(MODULE_NAME, "header.unknown2[{1}] = 0x{0:X8}", _header.unknown2[i], i);
AaruLogging.Debug(MODULE_NAME, "header.bcaOffset = {0}", _header.bcaOffset);
- for(int i = 0; i < _header.unknown3.Length; i++)
+ for(var i = 0; i < _header.unknown3.Length; i++)
AaruLogging.Debug(MODULE_NAME, "header.unknown3[{1}] = 0x{0:X8}", _header.unknown3[i], i);
AaruLogging.Debug(MODULE_NAME, "header.structuresOffset = {0}", _header.structuresOffset);
- for(int i = 0; i < _header.unknown4.Length; i++)
+ for(var i = 0; i < _header.unknown4.Length; i++)
AaruLogging.Debug(MODULE_NAME, "header.unknown4[{1}] = 0x{0:X8}", _header.unknown4[i], i);
AaruLogging.Debug(MODULE_NAME, "header.sessionOffset = {0}", _header.sessionOffset);
@@ -96,9 +96,9 @@ public sealed partial class Alcohol120
stream.Seek(_header.sessionOffset, SeekOrigin.Begin);
_alcSessions = new Dictionary();
- for(int i = 0; i < _header.sessions; i++)
+ for(var i = 0; i < _header.sessions; i++)
{
- byte[] sesHdr = new byte[24];
+ var sesHdr = new byte[24];
stream.EnsureRead(sesHdr, 0, 24);
Session session = Marshal.SpanToStructureLittleEndian(sesHdr);
@@ -124,7 +124,7 @@ public sealed partial class Alcohol120
}
long footerOff = 0;
- bool oldIncorrectImage = false;
+ var oldIncorrectImage = false;
_alcTracks = new Dictionary();
_alcToc = new Dictionary>();
@@ -135,9 +135,9 @@ public sealed partial class Alcohol120
stream.Seek(session.trackOffset, SeekOrigin.Begin);
Dictionary sesToc = new();
- for(int i = 0; i < session.allBlocks; i++)
+ for(var i = 0; i < session.allBlocks; i++)
{
- byte[] trkHdr = new byte[80];
+ var trkHdr = new byte[80];
stream.EnsureRead(trkHdr, 0, 80);
Track track = Marshal.ByteArrayToStructureLittleEndian