mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move declaration closer to usage.
This commit is contained in:
Submodule Aaru.Checksums updated: 695b9275ee...a9af82e47f
@@ -90,17 +90,18 @@ public static class ADC
|
||||
return AARU_adc_decode_buffer(destination, destination.Length, source, source.Length);
|
||||
|
||||
var inputPosition = 0;
|
||||
int chunkSize;
|
||||
int offset;
|
||||
int chunkType;
|
||||
var outPosition = 0;
|
||||
Span<byte> temp = stackalloc byte[3];
|
||||
var outPosition = 0;
|
||||
Span<byte> temp = stackalloc byte[3];
|
||||
|
||||
while(inputPosition < source.Length)
|
||||
{
|
||||
byte readByte = source[inputPosition++];
|
||||
|
||||
chunkType = GetChunkType(readByte);
|
||||
int chunkType = GetChunkType(readByte);
|
||||
|
||||
int chunkSize;
|
||||
|
||||
int offset;
|
||||
|
||||
switch(chunkType)
|
||||
{
|
||||
|
||||
@@ -57,8 +57,6 @@ public partial class Dump
|
||||
/// <summary>Dumps an ATA device</summary>
|
||||
void Ata()
|
||||
{
|
||||
bool recoveredError;
|
||||
|
||||
if(_outputPlugin is not IWritableImage outputFormat)
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("Image is not writable, aborting...");
|
||||
@@ -248,6 +246,8 @@ public partial class Dump
|
||||
// Setting geometry
|
||||
outputFormat.SetGeometry(cylinders, heads, sectors);
|
||||
|
||||
bool recoveredError;
|
||||
|
||||
if(ataReader.IsLba)
|
||||
{
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
|
||||
@@ -85,8 +85,7 @@ partial class Dump
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
byte[] readBuffer;
|
||||
Modes.DecodedMode? decMode = null;
|
||||
Modes.DecodedMode? decMode = null;
|
||||
bool ret;
|
||||
ExtentsULong blankExtents = null;
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
@@ -376,6 +375,8 @@ partial class Dump
|
||||
{
|
||||
if(outputFormat is IWritableOpticalImage opticalPlugin)
|
||||
{
|
||||
byte[] readBuffer;
|
||||
|
||||
sense = _dev.ReadDiscInformation(out readBuffer, out _, MmcDiscInformationDataTypes.DiscInformation,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
|
||||
@@ -200,7 +200,6 @@ public static class CompactDisc
|
||||
subLog.WriteRwFix(lba);
|
||||
}
|
||||
|
||||
byte smin, ssec, amin, asec, aframe;
|
||||
int aPos;
|
||||
|
||||
// Fix Q
|
||||
@@ -258,20 +257,20 @@ public static class CompactDisc
|
||||
!rwOk)
|
||||
continue;
|
||||
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
|
||||
if((q[0] & 0x3) == 1)
|
||||
{
|
||||
amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulong expectedSectorAddress = sectorAddress + (ulong)(subPos / 96) + 150;
|
||||
smin = (byte)(expectedSectorAddress / 60 / 75);
|
||||
var smin = (byte)(expectedSectorAddress / 60 / 75);
|
||||
expectedSectorAddress -= (ulong)(smin * 60 * 75);
|
||||
ssec = (byte)(expectedSectorAddress / 75);
|
||||
var ssec = (byte)(expectedSectorAddress / 75);
|
||||
|
||||
aPos = smin * 60 * 75 + ssec * 75 + aframe - 150;
|
||||
|
||||
@@ -875,9 +874,8 @@ public static class CompactDisc
|
||||
out bool fixedIndex, out bool fixedRelPos, out bool fixedAbsPos, out bool fixedCrc,
|
||||
out bool fixedMcn, out bool fixedIsrc)
|
||||
{
|
||||
byte amin, asec, aframe, pmin, psec, pframe;
|
||||
byte rmin, rsec, rframe;
|
||||
int aPos, rPos, pPos, dPos;
|
||||
byte aframe;
|
||||
byte rframe;
|
||||
controlFix = false;
|
||||
fixedZero = false;
|
||||
fixedTno = false;
|
||||
@@ -1049,18 +1047,26 @@ public static class CompactDisc
|
||||
return true;
|
||||
}
|
||||
|
||||
amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
|
||||
var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F));
|
||||
var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F));
|
||||
aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
|
||||
int aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
|
||||
|
||||
pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F));
|
||||
psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F));
|
||||
pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F));
|
||||
pPos = pmin * 60 * 75 + psec * 75 + pframe;
|
||||
var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F));
|
||||
var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F));
|
||||
var pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F));
|
||||
int pPos = pmin * 60 * 75 + psec * 75 + pframe;
|
||||
|
||||
// TODO: pregap
|
||||
// Not pregap
|
||||
byte rmin;
|
||||
|
||||
byte rsec;
|
||||
|
||||
int rPos;
|
||||
|
||||
int dPos;
|
||||
|
||||
if(q[2] > 0)
|
||||
{
|
||||
// Previous was not pregap either
|
||||
|
||||
@@ -48,8 +48,6 @@ public sealed partial class CPM
|
||||
/// <inheritdoc />
|
||||
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
||||
{
|
||||
ErrorNumber errno;
|
||||
|
||||
// This will only continue on devices with a chance to have ever been used by CP/M while failing on all others
|
||||
// It's ugly, but will stop a lot of false positives
|
||||
switch(imagePlugin.Info.MediaType)
|
||||
@@ -172,6 +170,8 @@ public sealed partial class CPM
|
||||
_label = null;
|
||||
|
||||
// Try Amstrad superblock
|
||||
ErrorNumber errno;
|
||||
|
||||
if(!_cpmFound)
|
||||
{
|
||||
// Read CHS = {0,0,1}
|
||||
|
||||
@@ -61,7 +61,6 @@ public sealed partial class FAT
|
||||
public ErrorNumber ReadDir(string path, out List<string> contents)
|
||||
{
|
||||
contents = null;
|
||||
ErrorNumber errno;
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
@@ -139,8 +138,8 @@ public sealed partial class FAT
|
||||
|
||||
for(var i = 0; i < clusters.Length; i++)
|
||||
{
|
||||
errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, _sectorsPerCluster,
|
||||
out byte[] buffer);
|
||||
ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, _sectorsPerCluster,
|
||||
out byte[] buffer);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
return errno;
|
||||
|
||||
@@ -91,8 +91,6 @@ public sealed partial class FAT
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Read(string path, long offset, long size, ref byte[] buf)
|
||||
{
|
||||
ErrorNumber errno;
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
@@ -137,8 +135,8 @@ public sealed partial class FAT
|
||||
if(i + firstCluster >= clusters.Length)
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
errno = _image.ReadSectors(_firstClusterSector + clusters[i + firstCluster] * _sectorsPerCluster,
|
||||
_sectorsPerCluster, out byte[] buffer);
|
||||
ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i + firstCluster] * _sectorsPerCluster,
|
||||
_sectorsPerCluster, out byte[] buffer);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
return errno;
|
||||
|
||||
@@ -542,7 +542,6 @@ public sealed partial class ISO9660
|
||||
hasResourceFork = false;
|
||||
var continueSymlink = false;
|
||||
var continueSymlinkComponent = false;
|
||||
AppleCommon.FInfo fInfo;
|
||||
|
||||
while(systemAreaOff + 2 <= end)
|
||||
{
|
||||
@@ -551,6 +550,8 @@ public sealed partial class ISO9660
|
||||
if(BigEndianBitConverter.ToUInt16(data, systemAreaOff + 6) == XA_MAGIC)
|
||||
systemAreaSignature = XA_MAGIC;
|
||||
|
||||
AppleCommon.FInfo fInfo;
|
||||
|
||||
switch(systemAreaSignature)
|
||||
{
|
||||
case APPLE_MAGIC:
|
||||
|
||||
@@ -387,7 +387,6 @@ public sealed partial class LisaFS
|
||||
ErrorNumber ReadFile(short fileId, out byte[] buf, bool tags)
|
||||
{
|
||||
buf = null;
|
||||
ErrorNumber errno;
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
@@ -422,11 +421,11 @@ public sealed partial class LisaFS
|
||||
{
|
||||
byte[] 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);
|
||||
ErrorNumber 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;
|
||||
|
||||
@@ -49,8 +49,6 @@ public sealed partial class LisaFS
|
||||
/// <inheritdoc />
|
||||
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
||||
{
|
||||
ErrorNumber errno;
|
||||
|
||||
if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true)
|
||||
return false;
|
||||
|
||||
@@ -63,7 +61,7 @@ public sealed partial class LisaFS
|
||||
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
|
||||
for(var i = 0; i < 100; i++)
|
||||
{
|
||||
errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag);
|
||||
ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
continue;
|
||||
@@ -137,7 +135,6 @@ public sealed partial class LisaFS
|
||||
Encoding = new LisaRoman();
|
||||
information = "";
|
||||
var sb = new StringBuilder();
|
||||
ErrorNumber errno;
|
||||
|
||||
if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true)
|
||||
return;
|
||||
@@ -151,7 +148,7 @@ public sealed partial class LisaFS
|
||||
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
|
||||
for(var i = 0; i < 100; i++)
|
||||
{
|
||||
errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag);
|
||||
ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
continue;
|
||||
|
||||
@@ -119,8 +119,6 @@ public sealed class SubdirectoryViewModel
|
||||
if(SelectedEntries.Count == 0)
|
||||
return;
|
||||
|
||||
ButtonResult mboxResult;
|
||||
|
||||
var saveFilesFolderDialog = new OpenFolderDialog
|
||||
{
|
||||
Title = "Choose destination folder..."
|
||||
@@ -139,6 +137,8 @@ public sealed class SubdirectoryViewModel
|
||||
{
|
||||
string filename = file.Name;
|
||||
|
||||
ButtonResult mboxResult;
|
||||
|
||||
if(DetectOS.IsWindows)
|
||||
if(filename.Contains('<') ||
|
||||
filename.Contains('>') ||
|
||||
|
||||
Submodule Aaru.Helpers updated: 70e03d4efb...c1196f636d
@@ -1955,7 +1955,6 @@ public sealed partial class AaruFormat
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)
|
||||
{
|
||||
ErrorNumber errno;
|
||||
buffer = null;
|
||||
|
||||
switch(_imageInfo.XmlMediaType)
|
||||
@@ -1976,7 +1975,7 @@ public sealed partial class AaruFormat
|
||||
return ReadSector(sectorAddress, out buffer);
|
||||
|
||||
buffer = new byte[2352];
|
||||
errno = ReadSector(sectorAddress, out byte[] data);
|
||||
ErrorNumber errno = ReadSector(sectorAddress, out byte[] data);
|
||||
|
||||
if(errno != ErrorNumber.NoError)
|
||||
return errno;
|
||||
|
||||
@@ -2584,15 +2584,14 @@ public sealed partial class AaruFormat
|
||||
|
||||
var cmpBuffer = new byte[mediaTag.Value.Length + 262144];
|
||||
|
||||
int cmpLen;
|
||||
byte[] lzmaProperties = null;
|
||||
var doNotCompress = false;
|
||||
|
||||
switch(_compressionAlgorithm)
|
||||
{
|
||||
case CompressionType.Lzma:
|
||||
cmpLen = LZMA.EncodeBuffer(mediaTag.Value, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, 0,
|
||||
2, 273);
|
||||
int cmpLen = LZMA.EncodeBuffer(mediaTag.Value, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, 0,
|
||||
2, 273);
|
||||
|
||||
if(cmpLen + LZMA_PROPERTIES_LENGTH > mediaTag.Value.Length)
|
||||
doNotCompress = true;
|
||||
|
||||
@@ -241,10 +241,6 @@ public sealed partial class WCDiskImage
|
||||
/// <param name="head">The head number of the track being read.</param>
|
||||
ErrorNumber ReadTrack(Stream stream, int cyl, int head)
|
||||
{
|
||||
byte[] sectorData;
|
||||
byte[] crc;
|
||||
short calculatedCRC;
|
||||
|
||||
for(var sect = 1; sect < _imageInfo.SectorsPerTrack + 1; sect++)
|
||||
{
|
||||
/* read the sector header */
|
||||
@@ -264,7 +260,7 @@ public sealed partial class WCDiskImage
|
||||
return ErrorNumber.InvalidArgument;
|
||||
}
|
||||
|
||||
sectorData = new byte[512];
|
||||
var sectorData = new byte[512];
|
||||
|
||||
/* read the sector data */
|
||||
switch(sheader.flag)
|
||||
@@ -272,8 +268,9 @@ public sealed partial class WCDiskImage
|
||||
case SectorFlag.Normal: /* read a normal sector and store it in cache */
|
||||
stream.Read(sectorData, 0, 512);
|
||||
_sectorCache[(cyl, head, sect)] = sectorData;
|
||||
byte[] crc;
|
||||
CRC16IBMContext.Data(sectorData, 512, out crc);
|
||||
calculatedCRC = (short)((256 * crc[0]) | crc[1]);
|
||||
var calculatedCRC = (short)((256 * crc[0]) | crc[1]);
|
||||
/*
|
||||
AaruConsole.DebugWriteLine("d2f plugin", "CHS {0},{1},{2}: Regular sector, stored CRC=0x{3:x4}, calculated CRC=0x{4:x4}",
|
||||
cyl, head, sect, sheader.crc, 256 * crc[0] + crc[1]);
|
||||
|
||||
@@ -37,12 +37,13 @@ public abstract class ImageReadIssueTest
|
||||
|
||||
ulong doneSectors = 0;
|
||||
var ctx = new Crc32Context();
|
||||
ErrorNumber errno;
|
||||
|
||||
while(doneSectors < image.Info.Sectors)
|
||||
{
|
||||
byte[] sector;
|
||||
|
||||
ErrorNumber errno;
|
||||
|
||||
if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ)
|
||||
{
|
||||
errno = image.ReadSectors(doneSectors, SECTORS_TO_READ, out sector);
|
||||
|
||||
@@ -46,7 +46,6 @@ public abstract class OpticalImageReadIssueTest
|
||||
ulong previousTrackEnd = 0;
|
||||
|
||||
List<Track> inputTracks = opticalInput.Tracks;
|
||||
ErrorNumber errno;
|
||||
|
||||
foreach(Track currentTrack in inputTracks)
|
||||
{
|
||||
@@ -57,6 +56,8 @@ public abstract class OpticalImageReadIssueTest
|
||||
{
|
||||
byte[] sector;
|
||||
|
||||
ErrorNumber errno;
|
||||
|
||||
if(sectors - doneSectors >= SECTORS_TO_READ)
|
||||
{
|
||||
errno = opticalInput.ReadSectors(doneSectors, SECTORS_TO_READ, currentTrack.Sequence, out sector);
|
||||
|
||||
Reference in New Issue
Block a user