Refactor IMediaImage.ReadSector(s)Tag to return error status instead of buffer.

This commit is contained in:
2021-09-20 20:52:18 +01:00
parent a6690aa121
commit 34df6087ce
72 changed files with 1538 additions and 933 deletions

View File

@@ -837,31 +837,23 @@ namespace Aaru.Core.Devices.Dumping
if((_outputPlugin as IWritableOpticalImage).Tracks != null)
foreach(Track imgTrack in (_outputPlugin as IWritableOpticalImage).Tracks)
{
try
{
byte[] isrcBytes =
(_outputPlugin as IWritableOpticalImage).ReadSectorTag(imgTrack.Sequence,
SectorTagType.CdTrackIsrc);
errno = (_outputPlugin as IWritableOpticalImage).ReadSectorTag(imgTrack.Sequence,
SectorTagType.CdTrackIsrc, out byte[] isrcBytes);
if(isrcBytes != null)
isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes);
}
catch(Exception)
{
// TODO: Replace for error number
}
if(errno == ErrorNumber.NoError)
isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes);
Track trk = tracks.FirstOrDefault(t => t.Sequence == imgTrack.Sequence);
if(trk != null)
{
trk.Pregap = imgTrack.Pregap;
trk.StartSector = imgTrack.StartSector;
trk.EndSector = imgTrack.EndSector;
if(trk == null)
continue;
foreach(KeyValuePair<ushort, int> imgIdx in imgTrack.Indexes)
trk.Indexes[imgIdx.Key] = imgIdx.Value;
}
trk.Pregap = imgTrack.Pregap;
trk.StartSector = imgTrack.StartSector;
trk.EndSector = imgTrack.EndSector;
foreach(KeyValuePair<ushort, int> imgIdx in imgTrack.Indexes)
trk.Indexes[imgIdx.Key] = imgIdx.Value;
}
// Send track list to output plugin. This may fail if subchannel is set but unsupported.

View File

@@ -185,12 +185,24 @@ namespace Aaru.Core.Devices.Dumping
if(!_storeEncrypted)
// Todo: Flag in the _outputPlugin that a sector has been decrypted
buffer = CSS.DecryptSector(buffer,
_outputPlugin.ReadSectorsTag(i, blocksToRead,
SectorTagType.DvdCmi),
_outputPlugin.ReadSectorsTag(i, blocksToRead,
SectorTagType.DvdTitleKeyDecrypted), blocksToRead,
blockSize);
{
ErrorNumber errno =
_outputPlugin.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdCmi, out byte[] cmi);
if(errno != ErrorNumber.NoError)
ErrorMessage?.Invoke($"Error retrieving CMI for sector {i}");
else
{
errno = _outputPlugin.ReadSectorsTag(i, blocksToRead,
SectorTagType.DvdTitleKeyDecrypted,
out byte[] titleKey);
if(errno != ErrorNumber.NoError)
ErrorMessage?.Invoke($"Error retrieving title key for sector {i}");
else
buffer = CSS.DecryptSector(buffer, cmi, titleKey, blocksToRead, blockSize);
}
}
}
mhddLog.Write(i, cmdDuration);

View File

@@ -705,38 +705,24 @@ namespace Aaru.Core
xmlTrk.FileSystemInformation[0].FileSystems = lstFs.ToArray();
}
try
{
byte[] isrcData = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackIsrc);
ErrorNumber errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcData);
if(isrcData?.Length > 0)
xmlTrk.ISRC = Encoding.UTF8.GetString(isrcData);
}
catch(Exception)
{
// Ignored
}
if(errno == ErrorNumber.NoError)
xmlTrk.ISRC = Encoding.UTF8.GetString(isrcData);
try
{
byte[] flagsData = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackFlags);
errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackFlags, out byte[] flagsData);
if(flagsData?.Length > 0)
if(errno == ErrorNumber.NoError)
{
var trackFlags = (CdFlags)flagsData[0];
xmlTrk.Flags = new TrackFlagsType
{
var trackFlags = (CdFlags)flagsData[0];
xmlTrk.Flags = new TrackFlagsType
{
PreEmphasis = trackFlags.HasFlag(CdFlags.PreEmphasis),
CopyPermitted = trackFlags.HasFlag(CdFlags.CopyPermitted),
Data = trackFlags.HasFlag(CdFlags.DataTrack),
Quadraphonic = trackFlags.HasFlag(CdFlags.FourChannel)
};
}
}
catch(Exception)
{
// Ignored
PreEmphasis = trackFlags.HasFlag(CdFlags.PreEmphasis),
CopyPermitted = trackFlags.HasFlag(CdFlags.CopyPermitted),
Data = trackFlags.HasFlag(CdFlags.DataTrack),
Quadraphonic = trackFlags.HasFlag(CdFlags.FourChannel)
};
}
if(trk.Indexes?.Count > 0)

View File

@@ -352,16 +352,14 @@ namespace Aaru.Filesystems
do
{
byte[] sectors;
ErrorNumber errno = ErrorNumber.NoError;
ErrorNumber errno;
if(tags)
sectors =
_device.
errno =
tags
? _device.
ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart,
(uint)_sectorsPerBlock, SectorTagType.AppleSectorTag);
else
errno =
_device.
(uint)_sectorsPerBlock, SectorTagType.AppleSectorTag, out sectors)
: _device.
ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart,
(uint)_sectorsPerBlock, out sectors);

View File

@@ -161,14 +161,14 @@ namespace Aaru.Filesystems
if(_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
{
_mdbTags = _device.ReadSectorTag(2 + _partitionStart, SectorTagType.AppleSectorTag);
_bootTags = _device.ReadSectorTag(0 + _partitionStart, SectorTagType.AppleSectorTag);
_device.ReadSectorTag(2 + _partitionStart, SectorTagType.AppleSectorTag, out _mdbTags);
_device.ReadSectorTag(0 + _partitionStart, SectorTagType.AppleSectorTag, out _bootTags);
_directoryTags = _device.ReadSectorsTag(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen,
SectorTagType.AppleSectorTag);
_device.ReadSectorsTag(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, SectorTagType.AppleSectorTag,
out _directoryTags);
_bitmapTags = _device.ReadSectorsTag(_partitionStart + 2, (uint)sectorsInWholeMdb,
SectorTagType.AppleSectorTag);
_device.ReadSectorsTag(_partitionStart + 2, (uint)sectorsInWholeMdb, SectorTagType.AppleSectorTag,
out _bitmapTags);
}
_sectorsPerBlock = (int)(_volMdb.drAlBlkSiz / _device.Info.SectorSize);

View File

@@ -583,18 +583,14 @@ namespace Aaru.Filesystems
while(leftExtentSize > 0)
{
try
{
byte[] fullSector =
_image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048,
SectorTagType.CdSectorSubHeader);
ErrorNumber errno =
_image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048,
SectorTagType.CdSectorSubHeader, out byte[] fullSector);
ms.Write(fullSector, copy ? 0 : 4, 4);
}
catch
{
// Do nothing
}
if(errno != ErrorNumber.NoError)
return null;
ms.Write(fullSector, copy ? 0 : 4, 4);
currentExtentSector++;
leftExtentSize -= 2048;

View File

@@ -176,7 +176,12 @@ namespace Aaru.Filesystems.LisaFS
// If root catalog is not pointed in MDDF (unchecked) maybe it's always following S-Records File?
for(ulong i = 0; i < _device.Info.Sectors; i++)
{
DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag catTag);
errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
continue;
DecodeTag(tag, out LisaTag.PriamTag catTag);
if(catTag.FileId != FILEID_CATALOG ||
catTag.RelPage != 0)
@@ -199,8 +204,13 @@ namespace Aaru.Filesystems.LisaFS
// Traverse double-linked list until first catalog block
while(prevCatalogPointer != 0xFFFFFFFF)
{
DecodeTag(_device.ReadSectorTag(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, SectorTagType.AppleSectorTag),
out LisaTag.PriamTag prevTag);
errno = _device.ReadSectorTag(prevCatalogPointer + _mddf.mddf_block + _volumePrefix,
SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
return errno;
DecodeTag(tag, out LisaTag.PriamTag prevTag);
if(prevTag.FileId != FILEID_CATALOG)
return ErrorNumber.InvalidArgument;
@@ -224,8 +234,13 @@ namespace Aaru.Filesystems.LisaFS
// Traverse double-linked list to read full catalog
while(nextCatalogPointer != 0xFFFFFFFF)
{
DecodeTag(_device.ReadSectorTag(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, SectorTagType.AppleSectorTag),
out LisaTag.PriamTag nextTag);
errno = _device.ReadSectorTag(nextCatalogPointer + _mddf.mddf_block + _volumePrefix,
SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
return errno;
DecodeTag(tag, out LisaTag.PriamTag nextTag);
if(nextTag.FileId != FILEID_CATALOG)
return ErrorNumber.InvalidArgument;

View File

@@ -83,6 +83,7 @@ namespace Aaru.Filesystems.LisaFS
ptr += _mddf.mddf_block + _volumePrefix;
LisaTag.PriamTag extTag;
byte[] tag;
// This happens on some disks.
// This is a filesystem corruption that makes LisaOS crash on scavenge.
@@ -93,7 +94,12 @@ namespace Aaru.Filesystems.LisaFS
for(ulong i = 0; i < _device.Info.Sectors; i++)
{
DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out extTag);
errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out tag);
if(errno != ErrorNumber.NoError)
continue;
DecodeTag(tag, out extTag);
if(extTag.FileId != fileId * -1)
continue;
@@ -109,7 +115,12 @@ namespace Aaru.Filesystems.LisaFS
}
// Checks that the sector tag indicates its the Extents File we are searching for
DecodeTag(_device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag);
errno = _device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag, out tag);
if(errno != ErrorNumber.NoError)
return errno;
DecodeTag(tag, out extTag);
if(extTag.FileId != (short)(-1 * fileId))
return ErrorNumber.NoSuchFile;

View File

@@ -225,10 +225,10 @@ namespace Aaru.Filesystems.LisaFS
}
else
{
buf = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len,
SectorTagType.AppleSectorTag);
errno = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len,
SectorTagType.AppleSectorTag, out buf);
return ErrorNumber.NoError;
return errno != ErrorNumber.NoError ? errno : ErrorNumber.NoError;
}
LisaTag.PriamTag sysTag;
@@ -236,7 +236,12 @@ namespace Aaru.Filesystems.LisaFS
// Should be enough to check 100 sectors?
for(ulong i = 0; i < 100; i++)
{
DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag);
errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
continue;
DecodeTag(tag, out sysTag);
if(sysTag.FileId == fileId)
count++;
@@ -250,22 +255,23 @@ namespace Aaru.Filesystems.LisaFS
// Should be enough to check 100 sectors?
for(ulong i = 0; i < 100; i++)
{
DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag);
errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
continue;
DecodeTag(tag, out sysTag);
if(sysTag.FileId != fileId)
continue;
byte[] sector;
if(!tags)
{
errno = _device.ReadSector(i, out sector);
errno = !tags ? _device.ReadSector(i, out sector)
: _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out sector);
if(errno != ErrorNumber.NoError)
continue;
}
else
sector = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag);
if(errno != ErrorNumber.NoError)
continue;
// Relative block for $Loader starts at $Boot block
if(sysTag.FileId == FILEID_LOADER_SIGNED)
@@ -418,17 +424,14 @@ namespace Aaru.Filesystems.LisaFS
{
byte[] sector;
if(!tags)
{
errno = _device.ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix,
(uint)file.extents[i].length, out sector);
errno = !tags ? _device.ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix,
(uint)file.extents[i].length, out sector)
: _device.ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix,
(uint)file.extents[i].length, SectorTagType.AppleSectorTag,
out sector);
if(errno != ErrorNumber.NoError)
return errno;
}
else
sector = _device.ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix,
(uint)file.extents[i].length, SectorTagType.AppleSectorTag);
if(errno != ErrorNumber.NoError)
return errno;
Array.Copy(sector, 0, temp, offset, sector.Length);
offset += sector.Length;

View File

@@ -51,89 +51,84 @@ namespace Aaru.Filesystems.LisaFS
{
ErrorNumber errno;
try
if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true)
return false;
// Minimal LisaOS disk is 3.5" single sided double density, 800 sectors
if(imagePlugin.Info.Sectors < 800)
return false;
int beforeMddf = -1;
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
for(int i = 0; i < 100; i++)
{
if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true)
return false;
errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag);
// Minimal LisaOS disk is 3.5" single sided double density, 800 sectors
if(imagePlugin.Info.Sectors < 800)
return false;
if(errno != ErrorNumber.NoError)
continue;
int beforeMddf = -1;
DecodeTag(tag, out LisaTag.PriamTag searchTag);
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
for(int i = 0; i < 100; i++)
AaruConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId);
if(beforeMddf == -1 &&
searchTag.FileId == FILEID_LOADER_SIGNED)
beforeMddf = i - 1;
if(searchTag.FileId != FILEID_MDDF)
continue;
errno = imagePlugin.ReadSector((ulong)i, out byte[] sector);
if(errno != ErrorNumber.NoError)
continue;
var infoMddf = new MDDF
{
DecodeTag(imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag),
out LisaTag.PriamTag searchTag);
mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C),
volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70),
volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74),
vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78),
blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C),
datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E)
};
AaruConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId);
AaruConsole.DebugWriteLine("LisaFS plugin", "Current sector = {0}", i);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", infoMddf.mddf_block);
AaruConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors", imagePlugin.Info.Sectors);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", infoMddf.vol_size);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}", infoMddf.volsize_minus_one);
if(beforeMddf == -1 &&
searchTag.FileId == FILEID_LOADER_SIGNED)
beforeMddf = i - 1;
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}",
infoMddf.volsize_minus_mddf_minus_one);
if(searchTag.FileId != FILEID_MDDF)
continue;
AaruConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes", imagePlugin.Info.SectorSize);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", infoMddf.blocksize);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", infoMddf.datasize);
errno = imagePlugin.ReadSector((ulong)i, out byte[] sector);
if(infoMddf.mddf_block != i - beforeMddf)
return false;
if(errno != ErrorNumber.NoError)
continue;
if(infoMddf.vol_size > imagePlugin.Info.Sectors)
return false;
var infoMddf = new MDDF
{
mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C),
volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70),
volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74),
vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78),
blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C),
datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E)
};
if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one)
return false;
AaruConsole.DebugWriteLine("LisaFS plugin", "Current sector = {0}", i);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", infoMddf.mddf_block);
AaruConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors", imagePlugin.Info.Sectors);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", infoMddf.vol_size);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}", infoMddf.volsize_minus_one);
if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf)
return false;
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}",
infoMddf.volsize_minus_mddf_minus_one);
if(infoMddf.datasize > infoMddf.blocksize)
return false;
AaruConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes", imagePlugin.Info.SectorSize);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", infoMddf.blocksize);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", infoMddf.datasize);
if(infoMddf.blocksize < imagePlugin.Info.SectorSize)
return false;
if(infoMddf.mddf_block != i - beforeMddf)
return false;
if(infoMddf.vol_size > imagePlugin.Info.Sectors)
return false;
if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one)
return false;
if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf)
return false;
if(infoMddf.datasize > infoMddf.blocksize)
return false;
if(infoMddf.blocksize < imagePlugin.Info.SectorSize)
return false;
return infoMddf.datasize == imagePlugin.Info.SectorSize;
}
return false;
return infoMddf.datasize == imagePlugin.Info.SectorSize;
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine("Exception {0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace);
return false;
}
return false;
}
/// <inheritdoc />
@@ -145,283 +140,279 @@ namespace Aaru.Filesystems.LisaFS
var sb = new StringBuilder();
ErrorNumber errno;
try
if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true)
return;
// Minimal LisaOS disk is 3.5" single sided double density, 800 sectors
if(imagePlugin.Info.Sectors < 800)
return;
int beforeMddf = -1;
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
for(int i = 0; i < 100; i++)
{
if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true)
errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
continue;
DecodeTag(tag, out LisaTag.PriamTag searchTag);
AaruConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId);
if(beforeMddf == -1 &&
searchTag.FileId == FILEID_LOADER_SIGNED)
beforeMddf = i - 1;
if(searchTag.FileId != FILEID_MDDF)
continue;
errno = imagePlugin.ReadSector((ulong)i, out byte[] sector);
if(errno != ErrorNumber.NoError)
continue;
var infoMddf = new MDDF();
byte[] pString = new byte[33];
infoMddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
infoMddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
infoMddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
infoMddf.volname = StringHandlers.PascalToString(pString, Encoding);
infoMddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
infoMddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : "";
infoMddf.unknown2 = sector[0x4F];
infoMddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
infoMddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58);
infoMddf.dtvc = DateHandlers.LisaToDateTime(lisaTime);
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C);
infoMddf.dtcc = DateHandlers.LisaToDateTime(lisaTime);
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x60);
infoMddf.dtvb = DateHandlers.LisaToDateTime(lisaTime);
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x64);
infoMddf.dtvs = DateHandlers.LisaToDateTime(lisaTime);
infoMddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
infoMddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
infoMddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
infoMddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
infoMddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
infoMddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
infoMddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
infoMddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
infoMddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
infoMddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
infoMddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
infoMddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
infoMddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
infoMddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
infoMddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
infoMddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
infoMddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
infoMddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
infoMddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
infoMddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
infoMddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
infoMddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
infoMddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
infoMddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
infoMddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
infoMddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
infoMddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
infoMddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
infoMddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
infoMddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
infoMddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
infoMddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
infoMddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
infoMddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
infoMddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
infoMddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
infoMddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
infoMddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
infoMddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
infoMddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
infoMddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
infoMddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
infoMddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
infoMddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
infoMddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
infoMddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
infoMddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
infoMddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
infoMddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
infoMddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
infoMddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
infoMddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
infoMddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
infoMddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
infoMddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
infoMddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
infoMddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
infoMddf.vol_left_mounted = sector[0x138];
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown1 = 0x{0:X2} ({0})", infoMddf.unknown1);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown2 = 0x{0:X2} ({0})", infoMddf.unknown2);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown3 = 0x{0:X8} ({0})", infoMddf.unknown3);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown4 = 0x{0:X4} ({0})", infoMddf.unknown4);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})", infoMddf.unknown5);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})", infoMddf.unknown6);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})", infoMddf.unknown7);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})", infoMddf.unknown9);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})", infoMddf.unknown10);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})", infoMddf.unknown11);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})", infoMddf.unknown12);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown13 = 0x{0:X8} ({0})", infoMddf.unknown13);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown14 = 0x{0:X8} ({0})", infoMddf.unknown14);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown15 = 0x{0:X8} ({0})", infoMddf.unknown15);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown16 = 0x{0:X8} ({0})", infoMddf.unknown16);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown17 = 0x{0:X4} ({0})", infoMddf.unknown17);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown18 = 0x{0:X8} ({0})", infoMddf.unknown18);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown19 = 0x{0:X8} ({0})", infoMddf.unknown19);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown20 = 0x{0:X8} ({0})", infoMddf.unknown20);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown21 = 0x{0:X8} ({0})", infoMddf.unknown21);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown22 = 0x{0:X8} ({0})", infoMddf.unknown22);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown23 = 0x{0:X8} ({0})", infoMddf.unknown23);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown24 = 0x{0:X8} ({0})", infoMddf.unknown24);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown25 = 0x{0:X8} ({0})", infoMddf.unknown25);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown26 = 0x{0:X8} ({0})", infoMddf.unknown26);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown27 = 0x{0:X8} ({0})", infoMddf.unknown27);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown28 = 0x{0:X8} ({0})", infoMddf.unknown28);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown29 = 0x{0:X8} ({0})", infoMddf.unknown29);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown30 = 0x{0:X8} ({0})", infoMddf.unknown30);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown31 = 0x{0:X8} ({0})", infoMddf.unknown31);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown32 = 0x{0:X8} ({0})", infoMddf.unknown32);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown33 = 0x{0:X8} ({0})", infoMddf.unknown33);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown34 = 0x{0:X8} ({0})", infoMddf.unknown34);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown35 = 0x{0:X8} ({0})", infoMddf.unknown35);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown36 = 0x{0:X8} ({0})", infoMddf.unknown36);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown37 = 0x{0:X8} ({0})", infoMddf.unknown37);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown38 = 0x{0:X8} ({0})", infoMddf.unknown38);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})",
infoMddf.unknown_timestamp,
DateHandlers.LisaToDateTime(infoMddf.unknown_timestamp));
if(infoMddf.mddf_block != i - beforeMddf)
return;
// Minimal LisaOS disk is 3.5" single sided double density, 800 sectors
if(imagePlugin.Info.Sectors < 800)
if(infoMddf.vol_size > imagePlugin.Info.Sectors)
return;
int beforeMddf = -1;
if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one)
return;
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
for(int i = 0; i < 100; i++)
if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf)
return;
if(infoMddf.datasize > infoMddf.blocksize)
return;
if(infoMddf.blocksize < imagePlugin.Info.SectorSize)
return;
if(infoMddf.datasize != imagePlugin.Info.SectorSize)
return;
switch(infoMddf.fsversion)
{
DecodeTag(imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag),
out LisaTag.PriamTag searchTag);
case LISA_V1:
sb.AppendLine("LisaFS v1");
AaruConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId);
break;
case LISA_V2:
sb.AppendLine("LisaFS v2");
if(beforeMddf == -1 &&
searchTag.FileId == FILEID_LOADER_SIGNED)
beforeMddf = i - 1;
break;
case LISA_V3:
sb.AppendLine("LisaFS v3");
if(searchTag.FileId != FILEID_MDDF)
continue;
break;
default:
sb.AppendFormat("Unknown LisaFS version {0}", infoMddf.fsversion).AppendLine();
errno = imagePlugin.ReadSector((ulong)i, out byte[] sector);
if(errno != ErrorNumber.NoError)
continue;
var infoMddf = new MDDF();
byte[] pString = new byte[33];
infoMddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
infoMddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
infoMddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
infoMddf.volname = StringHandlers.PascalToString(pString, Encoding);
infoMddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
infoMddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : "";
infoMddf.unknown2 = sector[0x4F];
infoMddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
infoMddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58);
infoMddf.dtvc = DateHandlers.LisaToDateTime(lisaTime);
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C);
infoMddf.dtcc = DateHandlers.LisaToDateTime(lisaTime);
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x60);
infoMddf.dtvb = DateHandlers.LisaToDateTime(lisaTime);
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x64);
infoMddf.dtvs = DateHandlers.LisaToDateTime(lisaTime);
infoMddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
infoMddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
infoMddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
infoMddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
infoMddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
infoMddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
infoMddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
infoMddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
infoMddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
infoMddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
infoMddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
infoMddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
infoMddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
infoMddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
infoMddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
infoMddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
infoMddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
infoMddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
infoMddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
infoMddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
infoMddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
infoMddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
infoMddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
infoMddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
infoMddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
infoMddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
infoMddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
infoMddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
infoMddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
infoMddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
infoMddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
infoMddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
infoMddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
infoMddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
infoMddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
infoMddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
infoMddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
infoMddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
infoMddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
infoMddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
infoMddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
infoMddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
infoMddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
infoMddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
infoMddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
infoMddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
infoMddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
infoMddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
infoMddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
infoMddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
infoMddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
infoMddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
infoMddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
infoMddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
infoMddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
infoMddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
infoMddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
infoMddf.vol_left_mounted = sector[0x138];
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown1 = 0x{0:X2} ({0})", infoMddf.unknown1);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown2 = 0x{0:X2} ({0})", infoMddf.unknown2);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown3 = 0x{0:X8} ({0})", infoMddf.unknown3);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown4 = 0x{0:X4} ({0})", infoMddf.unknown4);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})", infoMddf.unknown5);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})", infoMddf.unknown6);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})", infoMddf.unknown7);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})", infoMddf.unknown9);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})", infoMddf.unknown10);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})", infoMddf.unknown11);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})", infoMddf.unknown12);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown13 = 0x{0:X8} ({0})", infoMddf.unknown13);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown14 = 0x{0:X8} ({0})", infoMddf.unknown14);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown15 = 0x{0:X8} ({0})", infoMddf.unknown15);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown16 = 0x{0:X8} ({0})", infoMddf.unknown16);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown17 = 0x{0:X4} ({0})", infoMddf.unknown17);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown18 = 0x{0:X8} ({0})", infoMddf.unknown18);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown19 = 0x{0:X8} ({0})", infoMddf.unknown19);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown20 = 0x{0:X8} ({0})", infoMddf.unknown20);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown21 = 0x{0:X8} ({0})", infoMddf.unknown21);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown22 = 0x{0:X8} ({0})", infoMddf.unknown22);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown23 = 0x{0:X8} ({0})", infoMddf.unknown23);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown24 = 0x{0:X8} ({0})", infoMddf.unknown24);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown25 = 0x{0:X8} ({0})", infoMddf.unknown25);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown26 = 0x{0:X8} ({0})", infoMddf.unknown26);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown27 = 0x{0:X8} ({0})", infoMddf.unknown27);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown28 = 0x{0:X8} ({0})", infoMddf.unknown28);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown29 = 0x{0:X8} ({0})", infoMddf.unknown29);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown30 = 0x{0:X8} ({0})", infoMddf.unknown30);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown31 = 0x{0:X8} ({0})", infoMddf.unknown31);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown32 = 0x{0:X8} ({0})", infoMddf.unknown32);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown33 = 0x{0:X8} ({0})", infoMddf.unknown33);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown34 = 0x{0:X8} ({0})", infoMddf.unknown34);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown35 = 0x{0:X8} ({0})", infoMddf.unknown35);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown36 = 0x{0:X8} ({0})", infoMddf.unknown36);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown37 = 0x{0:X8} ({0})", infoMddf.unknown37);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown38 = 0x{0:X8} ({0})", infoMddf.unknown38);
AaruConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})",
infoMddf.unknown_timestamp,
DateHandlers.LisaToDateTime(infoMddf.unknown_timestamp));
if(infoMddf.mddf_block != i - beforeMddf)
return;
if(infoMddf.vol_size > imagePlugin.Info.Sectors)
return;
if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one)
return;
if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf)
return;
if(infoMddf.datasize > infoMddf.blocksize)
return;
if(infoMddf.blocksize < imagePlugin.Info.SectorSize)
return;
if(infoMddf.datasize != imagePlugin.Info.SectorSize)
return;
switch(infoMddf.fsversion)
{
case LISA_V1:
sb.AppendLine("LisaFS v1");
break;
case LISA_V2:
sb.AppendLine("LisaFS v2");
break;
case LISA_V3:
sb.AppendLine("LisaFS v3");
break;
default:
sb.AppendFormat("Unknown LisaFS version {0}", infoMddf.fsversion).AppendLine();
break;
}
sb.AppendFormat("Volume name: \"{0}\"", infoMddf.volname).AppendLine();
sb.AppendFormat("Volume password: \"{0}\"", infoMddf.password).AppendLine();
sb.AppendFormat("Volume ID: 0x{0:X16}", infoMddf.volid).AppendLine();
sb.AppendFormat("Backup volume ID: 0x{0:X16}", infoMddf.backup_volid).AppendLine();
sb.AppendFormat("Master copy ID: 0x{0:X8}", infoMddf.master_copy_id).AppendLine();
sb.AppendFormat("Volume is number {0} of {1}", infoMddf.volnum, infoMddf.vol_sequence).AppendLine();
sb.AppendFormat("Serial number of Lisa computer that created this volume: {0}",
infoMddf.machine_id).AppendLine();
sb.AppendFormat("Serial number of Lisa computer that can use this volume's software {0}",
infoMddf.serialization).AppendLine();
sb.AppendFormat("Volume created on {0}", infoMddf.dtvc).AppendLine();
sb.AppendFormat("Some timestamp, says {0}", infoMddf.dtcc).AppendLine();
sb.AppendFormat("Volume backed up on {0}", infoMddf.dtvb).AppendLine();
sb.AppendFormat("Volume scavenged on {0}", infoMddf.dtvs).AppendLine();
sb.AppendFormat("MDDF is in block {0}", infoMddf.mddf_block + beforeMddf).AppendLine();
sb.AppendFormat("There are {0} reserved blocks before volume", beforeMddf).AppendLine();
sb.AppendFormat("{0} blocks minus one", infoMddf.volsize_minus_one).AppendLine();
sb.AppendFormat("{0} blocks minus one minus MDDF offset", infoMddf.volsize_minus_mddf_minus_one).
AppendLine();
sb.AppendFormat("{0} blocks in volume", infoMddf.vol_size).AppendLine();
sb.AppendFormat("{0} bytes per sector (uncooked)", infoMddf.blocksize).AppendLine();
sb.AppendFormat("{0} bytes per sector", infoMddf.datasize).AppendLine();
sb.AppendFormat("{0} blocks per cluster", infoMddf.clustersize).AppendLine();
sb.AppendFormat("{0} blocks in filesystem", infoMddf.fs_size).AppendLine();
sb.AppendFormat("{0} files in volume", infoMddf.filecount).AppendLine();
sb.AppendFormat("{0} blocks free", infoMddf.freecount).AppendLine();
sb.AppendFormat("{0} bytes in LisaInfo", infoMddf.label_size).AppendLine();
sb.AppendFormat("Filesystem overhead: {0}", infoMddf.fs_overhead).AppendLine();
sb.AppendFormat("Scavenger result code: 0x{0:X8}", infoMddf.result_scavenge).AppendLine();
sb.AppendFormat("Boot code: 0x{0:X8}", infoMddf.boot_code).AppendLine();
sb.AppendFormat("Boot environment: 0x{0:X8}", infoMddf.boot_environ).AppendLine();
sb.AppendFormat("Overmount stamp: 0x{0:X16}", infoMddf.overmount_stamp).AppendLine();
sb.AppendFormat("S-Records start at {0} and spans for {1} blocks",
infoMddf.srec_ptr + infoMddf.mddf_block + beforeMddf, infoMddf.srec_len).
AppendLine();
sb.AppendLine(infoMddf.vol_left_mounted == 0 ? "Volume is clean" : "Volume is dirty");
information = sb.ToString();
XmlFsType = new FileSystemType();
if(DateTime.Compare(infoMddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
XmlFsType.BackupDate = infoMddf.dtvb;
XmlFsType.BackupDateSpecified = true;
}
XmlFsType.Clusters = infoMddf.vol_size;
XmlFsType.ClusterSize = (uint)(infoMddf.clustersize * infoMddf.datasize);
if(DateTime.Compare(infoMddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
XmlFsType.CreationDate = infoMddf.dtvc;
XmlFsType.CreationDateSpecified = true;
}
XmlFsType.Dirty = infoMddf.vol_left_mounted != 0;
XmlFsType.Files = infoMddf.filecount;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = infoMddf.freecount;
XmlFsType.FreeClustersSpecified = true;
XmlFsType.Type = "LisaFS";
XmlFsType.VolumeName = infoMddf.volname;
XmlFsType.VolumeSerial = $"{infoMddf.volid:X16}";
return;
break;
}
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine("Exception {0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace);
sb.AppendFormat("Volume name: \"{0}\"", infoMddf.volname).AppendLine();
sb.AppendFormat("Volume password: \"{0}\"", infoMddf.password).AppendLine();
sb.AppendFormat("Volume ID: 0x{0:X16}", infoMddf.volid).AppendLine();
sb.AppendFormat("Backup volume ID: 0x{0:X16}", infoMddf.backup_volid).AppendLine();
sb.AppendFormat("Master copy ID: 0x{0:X8}", infoMddf.master_copy_id).AppendLine();
sb.AppendFormat("Volume is number {0} of {1}", infoMddf.volnum, infoMddf.vol_sequence).AppendLine();
sb.AppendFormat("Serial number of Lisa computer that created this volume: {0}", infoMddf.machine_id).
AppendLine();
sb.AppendFormat("Serial number of Lisa computer that can use this volume's software {0}",
infoMddf.serialization).AppendLine();
sb.AppendFormat("Volume created on {0}", infoMddf.dtvc).AppendLine();
sb.AppendFormat("Some timestamp, says {0}", infoMddf.dtcc).AppendLine();
sb.AppendFormat("Volume backed up on {0}", infoMddf.dtvb).AppendLine();
sb.AppendFormat("Volume scavenged on {0}", infoMddf.dtvs).AppendLine();
sb.AppendFormat("MDDF is in block {0}", infoMddf.mddf_block + beforeMddf).AppendLine();
sb.AppendFormat("There are {0} reserved blocks before volume", beforeMddf).AppendLine();
sb.AppendFormat("{0} blocks minus one", infoMddf.volsize_minus_one).AppendLine();
sb.AppendFormat("{0} blocks minus one minus MDDF offset", infoMddf.volsize_minus_mddf_minus_one).
AppendLine();
sb.AppendFormat("{0} blocks in volume", infoMddf.vol_size).AppendLine();
sb.AppendFormat("{0} bytes per sector (uncooked)", infoMddf.blocksize).AppendLine();
sb.AppendFormat("{0} bytes per sector", infoMddf.datasize).AppendLine();
sb.AppendFormat("{0} blocks per cluster", infoMddf.clustersize).AppendLine();
sb.AppendFormat("{0} blocks in filesystem", infoMddf.fs_size).AppendLine();
sb.AppendFormat("{0} files in volume", infoMddf.filecount).AppendLine();
sb.AppendFormat("{0} blocks free", infoMddf.freecount).AppendLine();
sb.AppendFormat("{0} bytes in LisaInfo", infoMddf.label_size).AppendLine();
sb.AppendFormat("Filesystem overhead: {0}", infoMddf.fs_overhead).AppendLine();
sb.AppendFormat("Scavenger result code: 0x{0:X8}", infoMddf.result_scavenge).AppendLine();
sb.AppendFormat("Boot code: 0x{0:X8}", infoMddf.boot_code).AppendLine();
sb.AppendFormat("Boot environment: 0x{0:X8}", infoMddf.boot_environ).AppendLine();
sb.AppendFormat("Overmount stamp: 0x{0:X16}", infoMddf.overmount_stamp).AppendLine();
sb.AppendFormat("S-Records start at {0} and spans for {1} blocks",
infoMddf.srec_ptr + infoMddf.mddf_block + beforeMddf, infoMddf.srec_len).AppendLine();
sb.AppendLine(infoMddf.vol_left_mounted == 0 ? "Volume is clean" : "Volume is dirty");
information = sb.ToString();
XmlFsType = new FileSystemType();
if(DateTime.Compare(infoMddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
XmlFsType.BackupDate = infoMddf.dtvb;
XmlFsType.BackupDateSpecified = true;
}
XmlFsType.Clusters = infoMddf.vol_size;
XmlFsType.ClusterSize = (uint)(infoMddf.clustersize * infoMddf.datasize);
if(DateTime.Compare(infoMddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
XmlFsType.CreationDate = infoMddf.dtvc;
XmlFsType.CreationDateSpecified = true;
}
XmlFsType.Dirty = infoMddf.vol_left_mounted != 0;
XmlFsType.Files = infoMddf.filecount;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = infoMddf.freecount;
XmlFsType.FreeClustersSpecified = true;
XmlFsType.Type = "LisaFS";
XmlFsType.VolumeName = infoMddf.volname;
XmlFsType.VolumeSerial = $"{infoMddf.volid:X16}";
return;
}
}
}

View File

@@ -80,7 +80,12 @@ namespace Aaru.Filesystems.LisaFS
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
for(ulong i = 0; i < 100; i++)
{
DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag searchTag);
ErrorNumber errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
continue;
DecodeTag(tag, out LisaTag.PriamTag searchTag);
AaruConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId);
@@ -91,9 +96,8 @@ namespace Aaru.Filesystems.LisaFS
if(searchTag.FileId != FILEID_MDDF)
continue;
_devTagSize = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length;
ErrorNumber errno = _device.ReadSector(i, out byte[] sector);
_devTagSize = tag.Length;
errno = _device.ReadSector(i, out byte[] sector);
if(errno != ErrorNumber.NoError)
return errno;

View File

@@ -1072,9 +1072,9 @@ namespace Aaru.Gui.ViewModels.Windows
{
foreach(Track track in inputOptical.Tracks)
{
byte[] isrc = _inputFormat.ReadSectorTag(track.Sequence, tag);
errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc);
if(isrc is null)
if(errno != ErrorNumber.NoError)
continue;
isrcs[(byte)track.Sequence] = Encoding.UTF8.GetString(isrc);
@@ -1086,9 +1086,9 @@ namespace Aaru.Gui.ViewModels.Windows
{
foreach(Track track in inputOptical.Tracks)
{
byte[] flags = _inputFormat.ReadSectorTag(track.Sequence, tag);
errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags);
if(flags is null)
if(errno != ErrorNumber.NoError)
continue;
trackFlags[(byte)track.Sequence] = flags[0];
@@ -1161,46 +1161,104 @@ namespace Aaru.Gui.ViewModels.Windows
if(sectorsToDo == 1)
{
sector = _inputFormat.ReadSectorTag(doneSectors, tag);
Track track = tracks.LastOrDefault(t => t.StartSector >= doneSectors);
errno = _inputFormat.ReadSectorTag(doneSectors, tag, out sector);
if(tag == SectorTagType.CdSectorSubchannel &&
track != null)
if(errno == ErrorNumber.NoError)
{
bool indexesChanged = CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector, doneSectors, 1, null, isrcs, (byte)track.Sequence,
ref mcn, tracks.ToArray(), subchannelExtents, false, outputFormat, false,
false, null, null, smallestPregapLbaPerTrack, false);
Track track = tracks.LastOrDefault(t => t.StartSector >= doneSectors);
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
if(tag == SectorTagType.CdSectorSubchannel &&
track != null)
{
bool indexesChanged = CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector, doneSectors, 1, null, isrcs,
(byte)track.Sequence, ref mcn, tracks.ToArray(), subchannelExtents, false,
outputFormat, false, false, null, null, smallestPregapLbaPerTrack, false);
result = true;
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
result = true;
}
else
result = outputFormat.WriteSectorTag(sector, doneSectors, tag);
}
else
result = outputFormat.WriteSectorTag(sector, doneSectors, tag);
{
result = true;
if(ForceChecked)
{
warning = true;
AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno,
doneSectors);
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error).
ShowDialog(_view));
AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno,
doneSectors);
return;
}
}
}
else
{
sector = _inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag);
Track track = tracks.LastOrDefault(t => t.StartSector >= doneSectors);
if(tag == SectorTagType.CdSectorSubchannel &&
track != null)
errno = _inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag, out sector);
if(errno == ErrorNumber.NoError)
{
bool indexesChanged = CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector, doneSectors, sectorsToDo, null, isrcs,
(byte)track.Sequence, ref mcn, tracks.ToArray(), subchannelExtents, false,
outputFormat, false, false, null, null, smallestPregapLbaPerTrack, false);
Track track = tracks.LastOrDefault(t => t.StartSector >= doneSectors);
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
if(tag == SectorTagType.CdSectorSubchannel &&
track != null)
result = true;
{
bool indexesChanged = CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector, doneSectors, sectorsToDo, null, isrcs,
(byte)track.Sequence, ref mcn, tracks.ToArray(), subchannelExtents, false,
outputFormat, false, false, null, null, smallestPregapLbaPerTrack, false);
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
result = true;
}
else
result = outputFormat.WriteSectorsTag(sector, doneSectors, sectorsToDo, tag);
}
else
result = outputFormat.WriteSectorsTag(sector, doneSectors, sectorsToDo, tag);
{
result = true;
if(ForceChecked)
{
warning = true;
AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno,
doneSectors);
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error).
ShowDialog(_view));
AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno,
doneSectors);
return;
}
}
}
if(!result)
@@ -1437,8 +1495,32 @@ namespace Aaru.Gui.ViewModels.Windows
case SectorTagType.CdTrackFlags:
case SectorTagType.CdTrackIsrc:
sector = _inputFormat.ReadSectorTag(track.Sequence, tag);
result = outputFormat.WriteSectorTag(sector, track.Sequence, tag);
errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out sector);
if(errno == ErrorNumber.NoError)
result = outputFormat.WriteSectorTag(sector, track.Sequence, tag);
else
{
if(ForceChecked)
{
warning = true;
AaruConsole.ErrorWriteLine("Error {0} reading tag, continuing...", errno);
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () =>
await MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Error {errno} reading tag, not continuing...",
icon: Icon.Error).
ShowDialog(_view));
return;
}
continue;
}
if(!result)
if(ForceChecked)
@@ -1485,17 +1567,39 @@ namespace Aaru.Gui.ViewModels.Windows
Progress2Value = (int)(sectors / SectorsValue);
});
if(sectorsToDo == 1)
errno = sectorsToDo == 1
? _inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector)
: _inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo, tag,
out sector);
if(errno == ErrorNumber.NoError)
{
sector = _inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag);
result = outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag);
result = sectorsToDo == 1
? outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag)
: outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector,
sectorsToDo, tag);
}
else
{
sector = _inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo, tag);
result = true;
result = outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector,
sectorsToDo, tag);
if(ForceChecked)
{
warning = true;
AaruConsole.ErrorWriteLine("Error {0} reading tag for sector {1}, continuing...",
errno, doneSectors);
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Error {errno} reading tag for sector {doneSectors}, not continuing...",
icon: Icon.Error).
ShowDialog(_view));
return;
}
}
if(!result)

View File

@@ -1603,7 +1603,8 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track)
@@ -1632,7 +1633,9 @@ namespace Aaru.DiscImages
if(trk?.Sequence != track)
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
return ReadSectorTag(trk.StartSector + sectorAddress, tag);
ErrorNumber errno = ReadSectorTag(trk.StartSector + sectorAddress, tag, out byte[] buffer);
return errno != ErrorNumber.NoError ? null : buffer;
}
/// <inheritdoc />
@@ -1664,29 +1667,28 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
uint sectorOffset;
uint sectorSize;
uint sectorSkip;
byte[] dataSource;
buffer = null;
if(_imageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
{
Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && sectorAddress <= t.EndSector);
if(trk is null)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
"Can't found track containing requested sector");
return ErrorNumber.SectorNotFound;
if(trk.Sequence == 0 &&
trk.StartSector == 0 &&
trk.EndSector == 0)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
"Can't found track containing requested sector");
return ErrorNumber.SectorNotFound;
if(trk.Type == TrackType.Data)
throw new ArgumentException("Unsupported tag requested", nameof(tag));
return ErrorNumber.NotSupported;
switch(tag)
{
@@ -1702,14 +1704,23 @@ namespace Aaru.DiscImages
case SectorTagType.DvdTitleKey:
case SectorTagType.DvdTitleKeyDecrypted: break;
case SectorTagType.CdTrackFlags:
return _trackFlags.TryGetValue((byte)sectorAddress, out byte flags) ? new[]
if(!_trackFlags.TryGetValue((byte)sectorAddress, out byte flags))
return ErrorNumber.NoData;
buffer = new[]
{
flags
} : null;
};
return ErrorNumber.NoError;
case SectorTagType.CdTrackIsrc:
return _trackIsrcs.TryGetValue((byte)sectorAddress, out string isrc)
? Encoding.UTF8.GetBytes(isrc) : null;
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
if(!_trackIsrcs.TryGetValue((byte)sectorAddress, out string isrc))
return ErrorNumber.NoData;
buffer = Encoding.UTF8.GetBytes(isrc);
return ErrorNumber.NoError;
default: return ErrorNumber.NotSupported;
}
switch(trk.Type)
@@ -1737,8 +1748,7 @@ namespace Aaru.DiscImages
break;
}
case SectorTagType.CdSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CdSectorSubHeader: return ErrorNumber.NotSupported;
case SectorTagType.CdSectorEcc:
{
sectorOffset = 12;
@@ -1789,7 +1799,7 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
break;
@@ -1833,8 +1843,7 @@ namespace Aaru.DiscImages
case SectorTagType.CdSectorEcc:
case SectorTagType.CdSectorEccP:
case SectorTagType.CdSectorEccQ:
case SectorTagType.CdSectorEdc:
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CdSectorEdc: return ErrorNumber.NotSupported;
case SectorTagType.CdSectorSubchannel:
{
sectorOffset = 0;
@@ -1845,7 +1854,7 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
break;
@@ -1865,7 +1874,7 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
break;
@@ -1904,41 +1913,39 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
}
else
{
throw new ArgumentException("Unsupported tag requested", nameof(tag));
}
return ErrorNumber.NotSupported;
break;
}
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
default: return ErrorNumber.NotSupported;
}
}
else
throw new FeatureNotPresentImageException("Feature not present in image");
return ErrorNumber.NoData;
if(dataSource == null)
throw new ArgumentException("Unsupported tag requested", nameof(tag));
return ErrorNumber.NotSupported;
byte[] data = new byte[sectorSize * length];
buffer = new byte[sectorSize * length];
if(sectorOffset == 0 &&
sectorSkip == 0)
{
Array.Copy(dataSource, (long)(sectorAddress * sectorSize), data, 0, length * sectorSize);
Array.Copy(dataSource, (long)(sectorAddress * sectorSize), buffer, 0, length * sectorSize);
return data;
return ErrorNumber.NoError;
}
for(int i = 0; i < length; i++)
Array.Copy(dataSource, (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), data,
Array.Copy(dataSource, (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), buffer,
i * sectorSize, sectorSize);
return data;
return ErrorNumber.NoError;
}
/// <inheritdoc />
@@ -1976,7 +1983,9 @@ namespace Aaru.DiscImages
throw new ArgumentOutOfRangeException(nameof(length),
$"Requested more sectors ({length + sectorAddress}) than present in track ({trk.EndSector - trk.StartSector + 1}), won't cross tracks");
return ReadSectorsTag(trk.StartSector + sectorAddress, length, tag);
ErrorNumber errno = ReadSectorsTag(trk.StartSector + sectorAddress, length, tag, out byte[] buffer);
return errno == ErrorNumber.NoError ? buffer : null;
}
/// <inheritdoc />

View File

@@ -785,7 +785,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -819,8 +820,10 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in _offsetMap)
if(sectorAddress >= kvp.Value)
foreach(Track track in _alcTracks.Values)
@@ -829,11 +832,15 @@ namespace Aaru.DiscImages
!_alcTrackExtras.TryGetValue(track.point, out TrackExtra extra))
continue;
if(sectorAddress - kvp.Value < extra.sectors + extra.pregap)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
if(sectorAddress - kvp.Value >= extra.sectors + extra.pregap)
continue;
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class AppleDos
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -30,13 +30,11 @@
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Decoders.Floppy;
@@ -207,42 +205,48 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
$"Sector address {sectorAddress} not found");
return ErrorNumber.OutOfRange;
if(tag != SectorTagType.FloppyAddressMark)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
_addressFields.TryGetValue(sectorAddress, out byte[] temp);
return temp;
return _addressFields.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.NoData;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
$"Sector address {sectorAddress} not found");
return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
return ErrorNumber.OutOfRange;
if(tag != SectorTagType.FloppyAddressMark)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
var ms = new MemoryStream();
for(uint i = 0; i < length; i++)
{
byte[] sector = ReadSectorTag(sectorAddress + i, tag);
ErrorNumber errno = ReadSectorTag(sectorAddress + i, tag, out byte[] sector);
if(errno != ErrorNumber.NoError)
return errno;
ms.Write(sector, 0, sector.Length);
}
return ms.ToArray();
buffer = ms.ToArray();
return ErrorNumber.NoError;
}
/// <inheritdoc />

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -34,7 +34,6 @@ using System;
using System.IO;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Helpers;
@@ -157,7 +156,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
@@ -193,24 +193,26 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(tag != SectorTagType.AppleSectorTag)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
if(_bptag == 0)
throw new FeatureNotPresentImageException("Disk image does not have tags");
return ErrorNumber.NoData;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return ErrorNumber.SectorNotFound;
if(sectorAddress + length > _imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
return ErrorNumber.SectorNotFound;
var buffer = new MemoryStream();
int seek = 0x200;
int read = _bptag;
int skip = 0;
var ms = new MemoryStream();
int seek = 0x200;
int read = _bptag;
int skip = 0;
Stream stream = _bluImageFilter.GetDataForkStream();
stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin);
@@ -220,11 +222,13 @@ namespace Aaru.DiscImages
stream.Seek(seek, SeekOrigin.Current);
byte[] sector = new byte[read];
stream.Read(sector, 0, read);
buffer.Write(sector, 0, read);
ms.Write(sector, 0, read);
stream.Seek(skip, SeekOrigin.Current);
}
return buffer.ToArray();
buffer = ms.ToArray();
return ErrorNumber.NoError;
}
/// <inheritdoc />

View File

@@ -836,7 +836,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -864,15 +865,21 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <
track.EndSector - track.StartSector + 1 select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -1437,7 +1437,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -1465,15 +1466,21 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <
track.EndSector - track.StartSector + 1 select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -917,7 +917,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -945,15 +946,21 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value
from cdrdaoTrack in _discimage.Tracks
where cdrdaoTrack.Sequence == kvp.Key
where sectorAddress - kvp.Value < cdrdaoTrack.Sectors select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -1584,7 +1584,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -1612,19 +1613,29 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(tag == SectorTagType.CdTrackFlags ||
tag == SectorTagType.CdTrackIsrc)
return ReadSectorsTag(sectorAddress, length, 0, tag);
{
buffer = ReadSectorsTag(sectorAddress, length, 0, tag);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value
from cdrwinTrack in _discImage.Tracks
where cdrwinTrack.Sequence == kvp.Key
where sectorAddress - kvp.Value < cdrwinTrack.Sectors select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -1468,14 +1468,15 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(_isHdd)
throw new FeatureNotPresentImageException("Hard disk images do not have sector tags");
return ErrorNumber.NotSupported;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
$"Sector address {sectorAddress} not found");
return ErrorNumber.OutOfRange;
var track = new Track();
@@ -1501,23 +1502,24 @@ namespace Aaru.DiscImages
}
if(_isHdd)
return sector;
{
buffer = sector;
return ErrorNumber.NoError;
}
uint sectorOffset;
if(tag == SectorTagType.CdSectorSubchannel)
switch(track.SubchannelType)
{
case TrackSubchannelType.None:
throw new FeatureNotPresentImageException("Requested sector does not contain subchannel");
case TrackSubchannelType.None: return ErrorNumber.NoData;
case TrackSubchannelType.RawInterleaved:
sectorOffset = (uint)track.RawBytesPerSector;
sectorSize = 96;
break;
default:
throw new
FeatureSupportedButNotImplementedImageException($"Unsupported subchannel type {track.SubchannelType}");
default: return ErrorNumber.NotSupported;
}
else
switch(track.Type)
@@ -1544,9 +1546,7 @@ namespace Aaru.DiscImages
break;
}
case SectorTagType.CdSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track",
nameof(tag));
case SectorTagType.CdSectorSubHeader: return ErrorNumber.NotSupported;
case SectorTagType.CdSectorEcc:
{
sectorOffset = 2076;
@@ -1579,10 +1579,10 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
else
throw new FeatureNotPresentImageException("Requested sector does not contain tags");
return ErrorNumber.NoData;
break;
}
@@ -1624,7 +1624,7 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
else
switch(tag)
@@ -1634,9 +1634,7 @@ namespace Aaru.DiscImages
case SectorTagType.CdSectorSubchannel:
case SectorTagType.CdSectorEcc:
case SectorTagType.CdSectorEccP:
case SectorTagType.CdSectorEccQ:
throw new ArgumentException("Unsupported tag requested for this track",
nameof(tag));
case SectorTagType.CdSectorEccQ: return ErrorNumber.NotSupported;
case SectorTagType.CdSectorSubHeader:
{
sectorOffset = 0;
@@ -1653,7 +1651,7 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
break;
@@ -1668,9 +1666,7 @@ namespace Aaru.DiscImages
case SectorTagType.CdSectorHeader:
case SectorTagType.CdSectorEcc:
case SectorTagType.CdSectorEccP:
case SectorTagType.CdSectorEccQ:
throw new ArgumentException("Unsupported tag requested for this track",
nameof(tag));
case SectorTagType.CdSectorEccQ: return ErrorNumber.NotSupported;
case SectorTagType.CdSectorSubHeader:
{
sectorOffset = 0;
@@ -1687,20 +1683,19 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
else
throw new FeatureNotPresentImageException("Requested sector does not contain tags");
return ErrorNumber.NoData;
break;
}
case TrackType.Audio:
throw new FeatureNotPresentImageException("Requested sector does not contain tags");
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
case TrackType.Audio: return ErrorNumber.NoData;
default: return ErrorNumber.NotImplemented;
}
byte[] buffer = new byte[sectorSize];
buffer = new byte[sectorSize];
if(track.Type == TrackType.Audio && _swapAudio)
for(int i = 0; i < 2352; i += 2)
@@ -1720,7 +1715,7 @@ namespace Aaru.DiscImages
else
Array.Copy(sector, sectorOffset, buffer, 0, sectorSize);
return buffer;
return ErrorNumber.NoError;
}
/// <inheritdoc />
@@ -1752,25 +1747,31 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
$"Sector address {sectorAddress} not found");
return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length),
$"Requested more sectors ({sectorAddress + length}) than available ({_imageInfo.Sectors})");
return ErrorNumber.OutOfRange;
var ms = new MemoryStream();
for(uint i = 0; i < length; i++)
{
byte[] sector = ReadSectorTag(sectorAddress + i, tag);
ErrorNumber errno = ReadSectorTag(sectorAddress + i, tag, out byte[] sector);
if(errno != ErrorNumber.NoError)
return errno;
ms.Write(sector, 0, sector.Length);
}
return ms.ToArray();
buffer = ms.ToArray();
return ErrorNumber.NoError;
}
/// <inheritdoc />
@@ -1954,7 +1955,9 @@ namespace Aaru.DiscImages
if(_isHdd)
throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image");
return ReadSectorTag(GetAbsoluteSector(sectorAddress, track), tag);
ErrorNumber errno = ReadSectorTag(GetAbsoluteSector(sectorAddress, track), tag, out byte[] buffer);
return errno == ErrorNumber.NoError ? buffer : null;
}
/// <inheritdoc />
@@ -1974,7 +1977,9 @@ namespace Aaru.DiscImages
if(_isHdd)
throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image");
return ReadSectorsTag(GetAbsoluteSector(sectorAddress, track), length, tag);
ErrorNumber errno = ReadSectorsTag(GetAbsoluteSector(sectorAddress, track), length, tag, out byte[] buffer);
return errno == ErrorNumber.NoError ? buffer : null;
}
/// <inheritdoc />

View File

@@ -38,7 +38,6 @@ using System.Text;
using Aaru.Checksums;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Decoders.Floppy;
@@ -321,29 +320,30 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(tag != SectorTagType.FloppyAddressMark)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
if(_addressMarks.TryGetValue(sectorAddress, out byte[] addressMark))
return addressMark;
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return _addressMarks.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError
: ErrorNumber.SectorNotFound;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(tag != SectorTagType.FloppyAddressMark)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
$"Sector address {sectorAddress} not found");
return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
return ErrorNumber.OutOfRange;
var ms = new MemoryStream();
@@ -352,12 +352,14 @@ namespace Aaru.DiscImages
ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] addressMark);
if(errno != ErrorNumber.NoError)
return null;
return errno;
ms.Write(addressMark, 0, addressMark.Length);
}
return ms.ToArray();
buffer = ms.ToArray();
return ErrorNumber.NoError;
}
}
}

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class CisCopy
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -933,7 +933,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -961,8 +962,10 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in _offsetMap.Where(kvp => sectorAddress >= kvp.Value).
SelectMany(kvp => Tracks, (kvp, track) => new
{
@@ -972,9 +975,13 @@ namespace Aaru.DiscImages
Where(t => sectorAddress - t.kvp.Value <
t.track.EndSector - t.track.StartSector + 1).
Select(t => t.kvp))
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class CopyQm
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -328,7 +328,7 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
@@ -350,26 +350,28 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(tag != SectorTagType.AppleSectorTag)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
if(_tagCache == null ||
_tagCache.Length == 0)
throw new FeatureNotPresentImageException("Disk image does not have tags");
return ErrorNumber.NoData;
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
return ErrorNumber.OutOfRange;
byte[] buffer = new byte[length * TAG_SECTOR_SIZE];
buffer = new byte[length * TAG_SECTOR_SIZE];
Array.Copy(_tagCache, (int)sectorAddress * TAG_SECTOR_SIZE, buffer, 0, length * TAG_SECTOR_SIZE);
return buffer;
return ErrorNumber.NoError;
}
/// <inheritdoc />
@@ -392,7 +394,11 @@ namespace Aaru.DiscImages
if(errno != ErrorNumber.NoError)
return errno;
byte[] tags = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag);
errno = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag, out byte[] tags);
if(errno != ErrorNumber.NoError)
return errno;
buffer = new byte[data.Length + tags.Length];
for(uint i = 0; i < length; i++)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -139,8 +139,12 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new NotImplementedException("Flux decoding is not yet implemented.");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotImplemented;
}
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
@@ -151,8 +155,12 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new NotImplementedException("Flux decoding is not yet implemented.");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotImplemented;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) =>

View File

@@ -812,7 +812,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -840,15 +841,21 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <
track.EndSector - track.StartSector + 1 select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -35,7 +35,6 @@ using System.IO;
using System.Text.RegularExpressions;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Helpers;
@@ -472,7 +471,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
@@ -501,21 +501,23 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(tag != SectorTagType.AppleSectorTag)
throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format");
return ErrorNumber.NotSupported;
if(header.TagSize == 0)
throw new FeatureNotPresentImageException("Disk image does not have tags");
return ErrorNumber.NoData;
if(sectorAddress > imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return ErrorNumber.OutOfRange;
if(sectorAddress + length > imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
return ErrorNumber.OutOfRange;
byte[] buffer = new byte[length * bptag];
buffer = new byte[length * bptag];
if(twiggy)
Array.Copy(twiggyCacheTags, (int)sectorAddress * bptag, buffer, 0, length * bptag);
@@ -526,7 +528,7 @@ namespace Aaru.DiscImages
stream.Read(buffer, 0, (int)(length * bptag));
}
return buffer;
return ErrorNumber.NoError;
}
/// <inheritdoc />
@@ -549,7 +551,11 @@ namespace Aaru.DiscImages
if(errno != ErrorNumber.NoError)
return errno;
byte[] tags = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag);
errno = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag, out byte[] tags);
if(errno != ErrorNumber.NoError)
return errno;
buffer = new byte[data.Length + tags.Length];
for(uint i = 0; i < length; i++)

View File

@@ -32,7 +32,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -47,12 +46,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class DriDiskCopy
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -328,7 +328,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -364,21 +365,29 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value
from gdiTrack in _discImage.Tracks
where gdiTrack.Sequence == kvp.Key
where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
_offsetMap.TryGetValue(0, out ulong transitionStart);
if(sectorAddress >= transitionStart &&
sectorAddress < _densitySeparationSectors + transitionStart)
return ReadSectorsTag(sectorAddress - transitionStart, length, 0, tag);
if(sectorAddress < transitionStart ||
sectorAddress >= _densitySeparationSectors + transitionStart)
return ErrorNumber.SectorNotFound;
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
buffer = ReadSectorsTag(sectorAddress - transitionStart, length, 0, tag);
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
/// <inheritdoc />

View File

@@ -32,7 +32,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -47,12 +46,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Imd
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -268,8 +268,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new NotImplementedException("Flux decoding is not yet implemented.");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
@@ -280,8 +280,12 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new NotImplementedException("Flux decoding is not yet implemented.");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotImplemented;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) =>

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class MaxiDisk
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Ndif
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -1589,7 +1589,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => ReadSectorsTag(sectorAddress, 1, tag);
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public byte[] ReadSector(ulong sectorAddress, uint track) => ReadSectors(sectorAddress, 1, track);
@@ -1617,15 +1618,21 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value
from track in Tracks where track.Sequence == kvp.Key
where sectorAddress - kvp.Value <=
track.EndSector - track.StartSector select kvp)
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
{
buffer = ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found");
return buffer is null ? ErrorNumber.NoData : ErrorNumber.NoError;
}
return ErrorNumber.SectorNotFound;
}
/// <inheritdoc />

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Parallels
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class PartClone
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Partimage
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Qcow
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Qcow2
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Qed
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class RayDim
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class RsIde
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class SaveDskF
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -269,8 +269,8 @@ namespace Aaru.DiscImages
ReadSectors(sectorAddress, 1, out buffer);
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new NotImplementedException("Flux decoding is not yet implemented.");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer)
@@ -281,8 +281,12 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new NotImplementedException("Flux decoding is not yet implemented.");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotImplemented;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) =>

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,18 +31,25 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class TeleDisk
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
}
}

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Udif
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class Vdi
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,19 +31,26 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
public sealed partial class VMware
{
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
namespace Aaru.DiscImages
{
@@ -46,12 +45,20 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) =>
throw new FeatureUnsupportedImageException("Feature not supported by image format");
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
return ErrorNumber.NotSupported;
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)

View File

@@ -1400,33 +1400,39 @@ namespace Aaru.DiscImages
}
/// <inheritdoc />
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer)
{
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc ||
(!_rawCompactDisc && tag != SectorTagType.CdTrackFlags))
throw new FeatureUnsupportedImageException("Feature not supported by image format");
return ReadSectorsTag(sectorAddress, 1, tag);
return ReadSectorsTag(sectorAddress, 1, tag, out buffer);
}
/// <inheritdoc />
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
{
buffer = null;
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc ||
(!_rawCompactDisc && tag != SectorTagType.CdTrackFlags))
throw new FeatureUnsupportedImageException("Feature not supported by image format");
return ErrorNumber.NotSupported;
if(tag == SectorTagType.CdTrackFlags)
return new byte[]
{
buffer = new byte[]
{
4
};
return ErrorNumber.NoError;
}
if(sectorAddress > _imageInfo.Sectors - 1)
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
return ErrorNumber.OutOfRange;
if(sectorAddress + length > _imageInfo.Sectors)
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
return ErrorNumber.OutOfRange;
uint sectorOffset;
uint sectorSize;
@@ -1434,13 +1440,13 @@ namespace Aaru.DiscImages
if(!_hasSubchannel &&
tag == SectorTagType.CdSectorSubchannel)
throw new ArgumentException("No tags in image for requested track", nameof(tag));
return ErrorNumber.NoData;
// Requires reading sector
if(_mode2)
{
if(tag != SectorTagType.CdSectorSubchannel)
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
return ErrorNumber.NotImplemented;
sectorOffset = 2352;
sectorSize = 96;
@@ -1475,8 +1481,7 @@ namespace Aaru.DiscImages
break;
}
case SectorTagType.CdSectorSubHeader:
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
case SectorTagType.CdSectorSubHeader: return ErrorNumber.NotSupported;
case SectorTagType.CdSectorEcc:
{
sectorOffset = 2076;
@@ -1513,11 +1518,11 @@ namespace Aaru.DiscImages
break;
}
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
default: return ErrorNumber.NotSupported;
}
}
byte[] buffer = new byte[sectorSize * length];
buffer = new byte[sectorSize * length];
Stream stream = _rawImageFilter.GetDataForkStream();
var br = new BinaryReader(stream);
@@ -1535,7 +1540,7 @@ namespace Aaru.DiscImages
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
}
return buffer;
return ErrorNumber.NoError;
}
/// <inheritdoc />
@@ -1620,7 +1625,9 @@ namespace Aaru.DiscImages
if(track != 1)
throw new ArgumentOutOfRangeException(nameof(track), "Only a single track is supported");
return ReadSectorsTag(sectorAddress, length, tag);
ErrorNumber errno = ReadSectorsTag(sectorAddress, length, tag, out byte[] buffer);
return errno == ErrorNumber.NoError ? buffer : null;
}
}
}

View File

@@ -95,8 +95,16 @@ namespace Aaru.Tests.Images
latestEndSector = currentTrack.EndSector;
if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags))
flags[trackNo] = image.ReadSectorTag(currentTrack.Sequence,
SectorTagType.CdTrackFlags)[0];
{
ErrorNumber errno =
image.ReadSectorTag(currentTrack.Sequence, SectorTagType.CdTrackFlags,
out byte[] tmp);
if(errno != ErrorNumber.NoError)
continue;
flags[trackNo] = tmp[0];
}
trackNo++;
}

View File

@@ -142,7 +142,10 @@ namespace Aaru.Tests.Issues
if(UseLong)
{
errno = sectorsToDo == 1 ? inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector) : inputFormat.ReadSectorsLong(doneSectors + track.StartSector, sectorsToDo, out sector);
errno = sectorsToDo == 1
? inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector)
: inputFormat.ReadSectorsLong(doneSectors + track.StartSector, sectorsToDo,
out sector);
if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1
@@ -150,7 +153,7 @@ namespace Aaru.Tests.Issues
: outputOptical.WriteSectorsLong(sector, doneSectors + track.StartSector,
sectorsToDo);
else
result = false;
result = true;
if(!result &&
sector.Length % 2352 != 0)
@@ -208,9 +211,9 @@ namespace Aaru.Tests.Issues
{
foreach(Track track in tracks)
{
byte[] isrc = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc);
if(isrc is null)
if(errno != ErrorNumber.NoError)
continue;
isrcs[(byte)track.Sequence] = Encoding.UTF8.GetString(isrc);
@@ -222,9 +225,9 @@ namespace Aaru.Tests.Issues
{
foreach(Track track in tracks)
{
byte[] flags = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags);
if(flags is null)
if(errno != ErrorNumber.NoError)
continue;
trackFlags[(byte)track.Sequence] = flags[0];
@@ -269,7 +272,11 @@ namespace Aaru.Tests.Issues
{
case SectorTagType.CdTrackFlags:
case SectorTagType.CdTrackIsrc:
sector = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out sector);
Assert.AreEqual(ErrorNumber.NoError, errno,
$"Error {errno} reading tag, not continuing...");
result = outputOptical.WriteSectorTag(sector, track.Sequence, tag);
Assert.IsTrue(result, $"Error {outputOptical.ErrorMessage} writing tag, not continuing...");
@@ -288,7 +295,10 @@ namespace Aaru.Tests.Issues
if(sectorsToDo == 1)
{
sector = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag);
errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector);
Assert.AreEqual(ErrorNumber.NoError, errno,
$"Error {errno} reading tag, not continuing...");
if(tag == SectorTagType.CdSectorSubchannel)
{
@@ -307,7 +317,11 @@ namespace Aaru.Tests.Issues
}
else
{
sector = inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo, tag);
errno = inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo, tag,
out sector);
Assert.AreEqual(ErrorNumber.NoError, errno,
$"Error {errno} reading tag, not continuing...");
if(tag == SectorTagType.CdSectorSubchannel)
{

View File

@@ -25,6 +25,7 @@ namespace Aaru.Tests.WritableImages
public void Info()
{
Environment.CurrentDirectory = DataFolder;
ErrorNumber errno;
Assert.Multiple(() =>
{
@@ -92,8 +93,13 @@ namespace Aaru.Tests.WritableImages
latestEndSector = currentTrack.EndSector;
if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags))
flags[trackNo] = image.ReadSectorTag(currentTrack.Sequence,
SectorTagType.CdTrackFlags)[0];
{
errno = image.ReadSectorTag(currentTrack.Sequence, SectorTagType.CdTrackFlags,
out byte[] tmp);
if(errno != ErrorNumber.NoError)
flags[trackNo] = tmp[0];
}
trackNo++;
}
@@ -199,7 +205,10 @@ namespace Aaru.Tests.WritableImages
if(useLong)
{
errno = sectorsToDo == 1 ? inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector) : inputFormat.ReadSectorsLong(doneSectors + track.StartSector, sectorsToDo, out sector);
errno = sectorsToDo == 1
? inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector)
: inputFormat.ReadSectorsLong(doneSectors + track.StartSector, sectorsToDo,
out sector);
if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1
@@ -269,9 +278,9 @@ namespace Aaru.Tests.WritableImages
{
foreach(Track track in tracks)
{
byte[] isrc = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc);
if(isrc is null)
if(errno != ErrorNumber.NoError)
continue;
isrcs[(byte)track.Sequence] = Encoding.UTF8.GetString(isrc);
@@ -284,9 +293,9 @@ namespace Aaru.Tests.WritableImages
{
foreach(Track track in tracks)
{
byte[] flags = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags);
if(flags is null)
if(errno != ErrorNumber.NoError)
continue;
trackFlags[(byte)track.Sequence] = flags[0];
@@ -332,7 +341,11 @@ namespace Aaru.Tests.WritableImages
{
case SectorTagType.CdTrackFlags:
case SectorTagType.CdTrackIsrc:
sector = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out sector);
Assert.AreEqual(ErrorNumber.NoError, errno,
$"Error {errno} reading tag, not continuing...");
result = outputFormat.WriteSectorTag(sector, track.Sequence, tag);
Assert.IsTrue(result,
@@ -352,7 +365,10 @@ namespace Aaru.Tests.WritableImages
if(sectorsToDo == 1)
{
sector = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag);
errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector);
Assert.AreEqual(ErrorNumber.NoError, errno,
$"Error {errno} reading tag, not continuing...");
if(tag == SectorTagType.CdSectorSubchannel)
{
@@ -373,8 +389,11 @@ namespace Aaru.Tests.WritableImages
}
else
{
sector = inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo,
tag);
errno = inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo,
tag, out sector);
Assert.AreEqual(ErrorNumber.NoError, errno,
$"Error {errno} reading tag, not continuing...");
if(tag == SectorTagType.CdSectorSubchannel)
{
@@ -517,8 +536,13 @@ namespace Aaru.Tests.WritableImages
latestEndSector = currentTrack.EndSector;
if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags))
flags[trackNo] = image.ReadSectorTag(currentTrack.Sequence,
SectorTagType.CdTrackFlags)[0];
{
errno = image.ReadSectorTag(currentTrack.Sequence, SectorTagType.CdTrackFlags,
out byte[] tmp);
if(errno == ErrorNumber.NoError)
flags[trackNo] = tmp[0];
}
trackNo++;
}

View File

@@ -975,9 +975,9 @@ namespace Aaru.Commands.Image
{
foreach(Track track in tracks)
{
byte[] isrc = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc);
if(isrc is null)
if(errno != ErrorNumber.NoError)
continue;
isrcs[(byte)track.Sequence] = Encoding.UTF8.GetString(isrc);
@@ -989,9 +989,9 @@ namespace Aaru.Commands.Image
{
foreach(Track track in tracks)
{
byte[] flags = inputFormat.ReadSectorTag(track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags);
if(flags is null)
if(errno != ErrorNumber.NoError)
continue;
trackFlags[(byte)track.Sequence] = flags[0];
@@ -1049,8 +1049,29 @@ namespace Aaru.Commands.Image
{
case SectorTagType.CdTrackFlags:
case SectorTagType.CdTrackIsrc:
sector = inputFormat.ReadSectorTag(track.Sequence, tag);
result = outputFormat.WriteSectorTag(sector, track.Sequence, tag);
errno = inputFormat.ReadSectorTag(track.Sequence, tag, out sector);
if(errno == ErrorNumber.NoError)
result = outputFormat.WriteSectorTag(sector, track.Sequence, tag);
else
{
if(force)
{
AaruConsole.
ErrorWriteLine("Error {0} writing tag, continuing...",
outputFormat.ErrorMessage);
continue;
}
AaruConsole.
ErrorWriteLine("Error {0} writing tag, not continuing...",
outputFormat.ErrorMessage);
errno = ErrorNumber.WriteError;
return;
}
if(!result)
if(force)
@@ -1091,55 +1112,95 @@ namespace Aaru.Commands.Image
if(sectorsToDo == 1)
{
sector = inputFormat.ReadSectorTag(doneSectors + track.StartSector,
tag);
errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag,
out sector);
if(tag == SectorTagType.CdSectorSubchannel)
if(errno == ErrorNumber.NoError)
{
bool indexesChanged =
CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector,
doneSectors + track.StartSector, 1, null, isrcs,
(byte)track.Sequence, ref mcn, tracks,
subchannelExtents, fixSubchannelPosition, outputFormat,
fixSubchannel, fixSubchannelCrc, null, null,
smallestPregapLbaPerTrack, false);
if(tag == SectorTagType.CdSectorSubchannel)
{
bool indexesChanged =
CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector,
doneSectors + track.StartSector, 1, null, isrcs,
(byte)track.Sequence, ref mcn, tracks,
subchannelExtents, fixSubchannelPosition,
outputFormat, fixSubchannel, fixSubchannelCrc,
null, null, smallestPregapLbaPerTrack, false);
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
result = true;
result = true;
}
else
result =
outputFormat.WriteSectorTag(sector,
doneSectors + track.StartSector, tag);
}
else
result =
outputFormat.WriteSectorTag(sector,
doneSectors + track.StartSector, tag);
{
result = true;
if(force)
AaruConsole.
ErrorWriteLine("Error {0} reading tag for sector {1}, continuing...",
errno, doneSectors + track.StartSector);
else
{
AaruConsole.
ErrorWriteLine("Error {0} reading tag for sector {1}, not continuing...",
errno, doneSectors + track.StartSector);
return;
}
}
}
else
{
sector = inputFormat.ReadSectorsTag(doneSectors + track.StartSector,
sectorsToDo, tag);
errno = inputFormat.ReadSectorsTag(doneSectors + track.StartSector,
sectorsToDo, tag, out sector);
if(tag == SectorTagType.CdSectorSubchannel)
if(errno == ErrorNumber.NoError)
{
bool indexesChanged =
CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector,
doneSectors + track.StartSector, sectorsToDo, null,
isrcs, (byte)track.Sequence, ref mcn, tracks,
subchannelExtents, fixSubchannelPosition, outputFormat,
fixSubchannel, fixSubchannelCrc, null, null,
smallestPregapLbaPerTrack, false);
if(tag == SectorTagType.CdSectorSubchannel)
{
bool indexesChanged =
CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
MmcSubchannel.Raw, sector,
doneSectors + track.StartSector, sectorsToDo, null,
isrcs, (byte)track.Sequence, ref mcn, tracks,
subchannelExtents, fixSubchannelPosition,
outputFormat, fixSubchannel, fixSubchannelCrc,
null, null, smallestPregapLbaPerTrack, false);
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
if(indexesChanged)
outputOptical.SetTracks(tracks.ToList());
result = true;
result = true;
}
else
result =
outputFormat.WriteSectorsTag(sector,
doneSectors + track.StartSector, sectorsToDo, tag);
}
else
result =
outputFormat.WriteSectorsTag(sector,
doneSectors + track.StartSector, sectorsToDo, tag);
{
result = true;
if(force)
AaruConsole.
ErrorWriteLine("Error {0} reading tag for sector {1}, continuing...",
errno, doneSectors + track.StartSector);
else
{
AaruConsole.
ErrorWriteLine("Error {0} reading tag for sector {1}, not continuing...",
errno, doneSectors + track.StartSector);
return;
}
}
}
if(!result)
@@ -1303,10 +1364,8 @@ namespace Aaru.Commands.Image
: inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector);
if(errno == ErrorNumber.NoError)
{
result = sectorsToDo == 1 ? outputFormat.WriteSector(sector, doneSectors)
: outputFormat.WriteSectors(sector, doneSectors, sectorsToDo);
}
else
{
result = true;
@@ -1389,17 +1448,32 @@ namespace Aaru.Commands.Image
bool result;
if(sectorsToDo == 1)
{
sector = inputFormat.ReadSectorTag(doneSectors, tag);
result = outputFormat.WriteSectorTag(sector, doneSectors, tag);
}
errno = sectorsToDo == 1
? inputFormat.ReadSectorTag(doneSectors, tag, out sector)
: inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag,
out sector);
if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1
? outputFormat.WriteSectorTag(sector, doneSectors, tag)
: outputFormat.WriteSectorsTag(sector, doneSectors,
sectorsToDo, tag);
else
{
sector = inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag);
result = true;
result = outputFormat.WriteSectorsTag(sector, doneSectors, sectorsToDo,
tag);
if(force)
AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno,
doneSectors);
else
{
AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, not continuing...",
errno, doneSectors);
return;
}
}
if(!result)