mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Naming fixes.
This commit is contained in:
@@ -41,13 +41,13 @@ namespace Aaru.DiscImages
|
||||
// TODO: Check writing
|
||||
public partial class Apridisk : IWritableImage
|
||||
{
|
||||
ImageInfo imageInfo;
|
||||
ImageInfo _imageInfo;
|
||||
|
||||
// Cylinder by head, sector data matrix
|
||||
byte[][][][] sectorsData;
|
||||
FileStream writingStream;
|
||||
byte[][][][] _sectorsData;
|
||||
FileStream _writingStream;
|
||||
|
||||
public Apridisk() => imageInfo = new ImageInfo
|
||||
public Apridisk() => _imageInfo = new ImageInfo
|
||||
{
|
||||
ReadableSectorTags = new List<SectorTagType>(),
|
||||
ReadableMediaTags = new List<MediaTagType>(),
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
public partial class Apridisk
|
||||
{
|
||||
readonly byte[] signature =
|
||||
readonly byte[] _signature =
|
||||
{
|
||||
0x41, 0x43, 0x54, 0x20, 0x41, 0x70, 0x72, 0x69, 0x63, 0x6F, 0x74, 0x20, 0x64, 0x69, 0x73, 0x6B, 0x20, 0x69,
|
||||
0x6D, 0x61, 0x67, 0x65, 0x1A, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
(ushort cylinder, byte head, byte sector) LbaToChs(ulong lba)
|
||||
{
|
||||
ushort cylinder = (ushort)(lba / (imageInfo.Heads * imageInfo.SectorsPerTrack));
|
||||
byte head = (byte)((lba / imageInfo.SectorsPerTrack) % imageInfo.Heads);
|
||||
byte sector = (byte)((lba % imageInfo.SectorsPerTrack) + 1);
|
||||
ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack));
|
||||
byte head = (byte)((lba / _imageInfo.SectorsPerTrack) % _imageInfo.Heads);
|
||||
byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1);
|
||||
|
||||
return (cylinder, head, sector);
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ namespace Aaru.DiscImages
|
||||
Stream stream = imageFilter.GetDataForkStream();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if(stream.Length < signature.Length)
|
||||
if(stream.Length < _signature.Length)
|
||||
return false;
|
||||
|
||||
byte[] sigB = new byte[signature.Length];
|
||||
stream.Read(sigB, 0, signature.Length);
|
||||
byte[] sigB = new byte[_signature.Length];
|
||||
stream.Read(sigB, 0, _signature.Length);
|
||||
|
||||
return sigB.SequenceEqual(signature);
|
||||
return sigB.SequenceEqual(_signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
public partial class Apridisk
|
||||
{
|
||||
public ImageInfo Info => imageInfo;
|
||||
public ImageInfo Info => _imageInfo;
|
||||
|
||||
public string Name => "ACT Apricot Disk Image";
|
||||
public Guid Id => new Guid("43408CF3-6DB3-449F-A779-2B0E497C5B14");
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Aaru.DiscImages
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Skip signature
|
||||
stream.Seek(signature.Length, SeekOrigin.Begin);
|
||||
stream.Seek(_signature.Length, SeekOrigin.Begin);
|
||||
|
||||
int totalCylinders = -1;
|
||||
int totalHeads = -1;
|
||||
@@ -77,8 +77,8 @@ namespace Aaru.DiscImages
|
||||
stream.Seek(record.headerSize - recordSize, SeekOrigin.Current);
|
||||
byte[] commentB = new byte[record.dataSize];
|
||||
stream.Read(commentB, 0, commentB.Length);
|
||||
imageInfo.Comments = StringHandlers.CToString(commentB);
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin", "Comment: \"{0}\"", imageInfo.Comments);
|
||||
_imageInfo.Comments = StringHandlers.CToString(commentB);
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin", "Comment: \"{0}\"", _imageInfo.Comments);
|
||||
|
||||
break;
|
||||
case RecordType.Creator:
|
||||
@@ -86,8 +86,8 @@ namespace Aaru.DiscImages
|
||||
stream.Seek(record.headerSize - recordSize, SeekOrigin.Current);
|
||||
byte[] creatorB = new byte[record.dataSize];
|
||||
stream.Read(creatorB, 0, creatorB.Length);
|
||||
imageInfo.Creator = StringHandlers.CToString(creatorB);
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin", "Creator: \"{0}\"", imageInfo.Creator);
|
||||
_imageInfo.Creator = StringHandlers.CToString(creatorB);
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin", "Creator: \"{0}\"", _imageInfo.Creator);
|
||||
|
||||
break;
|
||||
case RecordType.Sector:
|
||||
@@ -127,13 +127,13 @@ namespace Aaru.DiscImages
|
||||
totalHeads <= 0)
|
||||
throw new ImageNotSupportedException("No cylinders or heads found");
|
||||
|
||||
sectorsData = new byte[totalCylinders][][][];
|
||||
_sectorsData = new byte[totalCylinders][][][];
|
||||
|
||||
// Total sectors per track
|
||||
uint[][] spts = new uint[totalCylinders][];
|
||||
|
||||
imageInfo.Cylinders = (ushort)totalCylinders;
|
||||
imageInfo.Heads = (byte)totalHeads;
|
||||
_imageInfo.Cylinders = (ushort)totalCylinders;
|
||||
_imageInfo.Heads = (byte)totalHeads;
|
||||
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin",
|
||||
"Found {0} cylinders and {1} heads with a maximum sector number of {2}",
|
||||
@@ -142,19 +142,19 @@ namespace Aaru.DiscImages
|
||||
// Create heads
|
||||
for(int i = 0; i < totalCylinders; i++)
|
||||
{
|
||||
sectorsData[i] = new byte[totalHeads][][];
|
||||
spts[i] = new uint[totalHeads];
|
||||
_sectorsData[i] = new byte[totalHeads][][];
|
||||
spts[i] = new uint[totalHeads];
|
||||
|
||||
for(int j = 0; j < totalHeads; j++)
|
||||
sectorsData[i][j] = new byte[maxSector + 1][];
|
||||
_sectorsData[i][j] = new byte[maxSector + 1][];
|
||||
}
|
||||
|
||||
imageInfo.SectorSize = uint.MaxValue;
|
||||
_imageInfo.SectorSize = uint.MaxValue;
|
||||
|
||||
ulong headersizes = 0;
|
||||
|
||||
// Read sectors
|
||||
stream.Seek(signature.Length, SeekOrigin.Begin);
|
||||
stream.Seek(_signature.Length, SeekOrigin.Begin);
|
||||
|
||||
while(stream.Position < stream.Length)
|
||||
{
|
||||
@@ -183,12 +183,13 @@ namespace Aaru.DiscImages
|
||||
uint realLength = record.dataSize;
|
||||
|
||||
if(record.compression == CompressType.Compressed)
|
||||
realLength = Decompress(data, out sectorsData[record.cylinder][record.head][record.sector]);
|
||||
realLength =
|
||||
Decompress(data, out _sectorsData[record.cylinder][record.head][record.sector]);
|
||||
else
|
||||
sectorsData[record.cylinder][record.head][record.sector] = data;
|
||||
_sectorsData[record.cylinder][record.head][record.sector] = data;
|
||||
|
||||
if(realLength < imageInfo.SectorSize)
|
||||
imageInfo.SectorSize = realLength;
|
||||
if(realLength < _imageInfo.SectorSize)
|
||||
_imageInfo.SectorSize = realLength;
|
||||
|
||||
headersizes += record.headerSize + record.dataSize;
|
||||
|
||||
@@ -197,33 +198,33 @@ namespace Aaru.DiscImages
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin", "Found a minimum of {0} bytes per sector",
|
||||
imageInfo.SectorSize);
|
||||
_imageInfo.SectorSize);
|
||||
|
||||
// Count sectors per track
|
||||
uint spt = uint.MaxValue;
|
||||
|
||||
for(ushort cyl = 0; cyl < imageInfo.Cylinders; cyl++)
|
||||
for(ushort cyl = 0; cyl < _imageInfo.Cylinders; cyl++)
|
||||
{
|
||||
for(ushort head = 0; head < imageInfo.Heads; head++)
|
||||
for(ushort head = 0; head < _imageInfo.Heads; head++)
|
||||
if(spts[cyl][head] < spt)
|
||||
spt = spts[cyl][head];
|
||||
}
|
||||
|
||||
imageInfo.SectorsPerTrack = spt;
|
||||
_imageInfo.SectorsPerTrack = spt;
|
||||
|
||||
AaruConsole.DebugWriteLine("Apridisk plugin", "Found a minimum of {0} sectors per track",
|
||||
imageInfo.SectorsPerTrack);
|
||||
_imageInfo.SectorsPerTrack);
|
||||
|
||||
imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads,
|
||||
(ushort)imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM,
|
||||
false));
|
||||
_imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads,
|
||||
(ushort)_imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM,
|
||||
false));
|
||||
|
||||
imageInfo.ImageSize = (ulong)stream.Length - headersizes;
|
||||
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
||||
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
||||
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
||||
imageInfo.Sectors = imageInfo.Cylinders * imageInfo.Heads * imageInfo.SectorsPerTrack;
|
||||
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
||||
_imageInfo.ImageSize = (ulong)stream.Length - headersizes;
|
||||
_imageInfo.CreationTime = imageFilter.GetCreationTime();
|
||||
_imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
||||
_imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
||||
_imageInfo.Sectors = _imageInfo.Cylinders * _imageInfo.Heads * _imageInfo.SectorsPerTrack;
|
||||
_imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -232,24 +233,24 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
(ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress);
|
||||
|
||||
if(cylinder >= sectorsData.Length)
|
||||
if(cylinder >= _sectorsData.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
||||
|
||||
if(head >= sectorsData[cylinder].Length)
|
||||
if(head >= _sectorsData[cylinder].Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
||||
|
||||
if(sector > sectorsData[cylinder][head].Length)
|
||||
if(sector > _sectorsData[cylinder][head].Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
||||
|
||||
return sectorsData[cylinder][head][sector];
|
||||
return _sectorsData[cylinder][head][sector];
|
||||
}
|
||||
|
||||
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
||||
{
|
||||
if(sectorAddress > imageInfo.Sectors - 1)
|
||||
if(sectorAddress > _imageInfo.Sectors - 1)
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
||||
|
||||
if(sectorAddress + length > imageInfo.Sectors)
|
||||
if(sectorAddress + length > _imageInfo.Sectors)
|
||||
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
||||
|
||||
var buffer = new MemoryStream();
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Aaru.DiscImages
|
||||
return false;
|
||||
}
|
||||
|
||||
imageInfo = new ImageInfo
|
||||
_imageInfo = new ImageInfo
|
||||
{
|
||||
MediaType = mediaType,
|
||||
SectorSize = sectorSize,
|
||||
@@ -64,7 +64,7 @@ namespace Aaru.DiscImages
|
||||
|
||||
try
|
||||
{
|
||||
writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
|
||||
_writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
@@ -90,28 +90,28 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
(ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress);
|
||||
|
||||
if(cylinder >= sectorsData.Length)
|
||||
if(cylinder >= _sectorsData.Length)
|
||||
{
|
||||
ErrorMessage = "Sector address not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(head >= sectorsData[cylinder].Length)
|
||||
if(head >= _sectorsData[cylinder].Length)
|
||||
{
|
||||
ErrorMessage = "Sector address not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sector > sectorsData[cylinder][head].Length)
|
||||
if(sector > _sectorsData[cylinder][head].Length)
|
||||
{
|
||||
ErrorMessage = "Sector address not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sectorsData[cylinder][head][sector] = data;
|
||||
_sectorsData[cylinder][head][sector] = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -122,28 +122,28 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
(ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress);
|
||||
|
||||
if(cylinder >= sectorsData.Length)
|
||||
if(cylinder >= _sectorsData.Length)
|
||||
{
|
||||
ErrorMessage = "Sector address not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(head >= sectorsData[cylinder].Length)
|
||||
if(head >= _sectorsData[cylinder].Length)
|
||||
{
|
||||
ErrorMessage = "Sector address not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sector > sectorsData[cylinder][head].Length)
|
||||
if(sector > _sectorsData[cylinder][head].Length)
|
||||
{
|
||||
ErrorMessage = "Sector address not found";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sectorsData[cylinder][head][sector] = data;
|
||||
_sectorsData[cylinder][head][sector] = data;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -166,19 +166,19 @@ namespace Aaru.DiscImages
|
||||
// TODO: Try if apridisk software supports finding other chunks, to extend metadata support
|
||||
public bool Close()
|
||||
{
|
||||
writingStream.Seek(0, SeekOrigin.Begin);
|
||||
writingStream.Write(signature, 0, signature.Length);
|
||||
_writingStream.Seek(0, SeekOrigin.Begin);
|
||||
_writingStream.Write(_signature, 0, _signature.Length);
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ApridiskRecord>()];
|
||||
|
||||
for(ushort c = 0; c < imageInfo.Cylinders; c++)
|
||||
for(ushort c = 0; c < _imageInfo.Cylinders; c++)
|
||||
{
|
||||
for(byte h = 0; h < imageInfo.Heads; h++)
|
||||
for(byte h = 0; h < _imageInfo.Heads; h++)
|
||||
{
|
||||
for(byte s = 0; s < imageInfo.SectorsPerTrack; s++)
|
||||
for(byte s = 0; s < _imageInfo.SectorsPerTrack; s++)
|
||||
{
|
||||
if(sectorsData[c][h][s] == null ||
|
||||
sectorsData[c][h][s].Length == 0)
|
||||
if(_sectorsData[c][h][s] == null ||
|
||||
_sectorsData[c][h][s].Length == 0)
|
||||
continue;
|
||||
|
||||
var record = new ApridiskRecord
|
||||
@@ -186,7 +186,7 @@ namespace Aaru.DiscImages
|
||||
type = RecordType.Sector,
|
||||
compression = CompressType.Uncompresed,
|
||||
headerSize = (ushort)Marshal.SizeOf<ApridiskRecord>(),
|
||||
dataSize = (uint)sectorsData[c][h][s].Length,
|
||||
dataSize = (uint)_sectorsData[c][h][s].Length,
|
||||
head = h,
|
||||
sector = s,
|
||||
cylinder = c
|
||||
@@ -194,15 +194,15 @@ namespace Aaru.DiscImages
|
||||
|
||||
MemoryMarshal.Write(hdr, ref record);
|
||||
|
||||
writingStream.Write(hdr, 0, hdr.Length);
|
||||
writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length);
|
||||
_writingStream.Write(hdr, 0, hdr.Length);
|
||||
_writingStream.Write(_sectorsData[c][h][s], 0, _sectorsData[c][h][s].Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!string.IsNullOrEmpty(imageInfo.Creator))
|
||||
if(!string.IsNullOrEmpty(_imageInfo.Creator))
|
||||
{
|
||||
byte[] creatorBytes = Encoding.UTF8.GetBytes(imageInfo.Creator);
|
||||
byte[] creatorBytes = Encoding.UTF8.GetBytes(_imageInfo.Creator);
|
||||
|
||||
var creatorRecord = new ApridiskRecord
|
||||
{
|
||||
@@ -217,14 +217,14 @@ namespace Aaru.DiscImages
|
||||
|
||||
MemoryMarshal.Write(hdr, ref creatorRecord);
|
||||
|
||||
writingStream.Write(hdr, 0, hdr.Length);
|
||||
writingStream.Write(creatorBytes, 0, creatorBytes.Length);
|
||||
writingStream.WriteByte(0); // Termination
|
||||
_writingStream.Write(hdr, 0, hdr.Length);
|
||||
_writingStream.Write(creatorBytes, 0, creatorBytes.Length);
|
||||
_writingStream.WriteByte(0); // Termination
|
||||
}
|
||||
|
||||
if(!string.IsNullOrEmpty(imageInfo.Comments))
|
||||
if(!string.IsNullOrEmpty(_imageInfo.Comments))
|
||||
{
|
||||
byte[] commentBytes = Encoding.UTF8.GetBytes(imageInfo.Comments);
|
||||
byte[] commentBytes = Encoding.UTF8.GetBytes(_imageInfo.Comments);
|
||||
|
||||
var commentRecord = new ApridiskRecord
|
||||
{
|
||||
@@ -239,13 +239,13 @@ namespace Aaru.DiscImages
|
||||
|
||||
MemoryMarshal.Write(hdr, ref commentRecord);
|
||||
|
||||
writingStream.Write(hdr, 0, hdr.Length);
|
||||
writingStream.Write(commentBytes, 0, commentBytes.Length);
|
||||
writingStream.WriteByte(0); // Termination
|
||||
_writingStream.Write(hdr, 0, hdr.Length);
|
||||
_writingStream.Write(commentBytes, 0, commentBytes.Length);
|
||||
_writingStream.WriteByte(0); // Termination
|
||||
}
|
||||
|
||||
writingStream.Flush();
|
||||
writingStream.Close();
|
||||
_writingStream.Flush();
|
||||
_writingStream.Close();
|
||||
|
||||
IsWriting = false;
|
||||
ErrorMessage = "";
|
||||
@@ -255,8 +255,8 @@ namespace Aaru.DiscImages
|
||||
|
||||
public bool SetMetadata(ImageInfo metadata)
|
||||
{
|
||||
imageInfo.Comments = metadata.Comments;
|
||||
imageInfo.Creator = metadata.Creator;
|
||||
_imageInfo.Comments = metadata.Comments;
|
||||
_imageInfo.Creator = metadata.Creator;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -284,19 +284,19 @@ namespace Aaru.DiscImages
|
||||
return false;
|
||||
}
|
||||
|
||||
sectorsData = new byte[cylinders][][][];
|
||||
_sectorsData = new byte[cylinders][][][];
|
||||
|
||||
for(ushort c = 0; c < cylinders; c++)
|
||||
{
|
||||
sectorsData[c] = new byte[heads][][];
|
||||
_sectorsData[c] = new byte[heads][][];
|
||||
|
||||
for(byte h = 0; h < heads; h++)
|
||||
sectorsData[c][h] = new byte[sectorsPerTrack][];
|
||||
_sectorsData[c][h] = new byte[sectorsPerTrack][];
|
||||
}
|
||||
|
||||
imageInfo.Cylinders = cylinders;
|
||||
imageInfo.Heads = heads;
|
||||
imageInfo.SectorsPerTrack = sectorsPerTrack;
|
||||
_imageInfo.Cylinders = cylinders;
|
||||
_imageInfo.Heads = heads;
|
||||
_imageInfo.SectorsPerTrack = sectorsPerTrack;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user