mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use index from end expression.
This commit is contained in:
Submodule Aaru.CommonTypes updated: fe4e055fbc...e4c32b05ee
@@ -372,7 +372,7 @@ namespace Aaru.Core.Devices.Dumping
|
|||||||
for(int t = 1; t < tracks.Length; t++)
|
for(int t = 1; t < tracks.Length; t++)
|
||||||
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
||||||
|
|
||||||
tracks[tracks.Length - 1].TrackEndSector = (ulong)lastSector;
|
tracks[^1].TrackEndSector = (ulong)lastSector;
|
||||||
blocks = (ulong)(lastSector + 1);
|
blocks = (ulong)(lastSector + 1);
|
||||||
|
|
||||||
if(blocks == 0)
|
if(blocks == 0)
|
||||||
|
|||||||
@@ -834,7 +834,7 @@ namespace Aaru.Devices
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Manufacturer = separated[0];
|
Manufacturer = separated[0];
|
||||||
Model = separated[separated.Length - 1];
|
Model = separated[^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
FirmwareRevision = ataid.Value.FirmwareRevision;
|
FirmwareRevision = ataid.Value.FirmwareRevision;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace Aaru.Devices.FreeBSD
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
deviceInfo.Vendor = separated[0];
|
deviceInfo.Vendor = separated[0];
|
||||||
deviceInfo.Model = separated[separated.Length - 1];
|
deviceInfo.Model = separated[^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceInfo.Serial = idt.Value.SerialNumber;
|
deviceInfo.Serial = idt.Value.SerialNumber;
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ namespace Aaru.Filesystems.FAT
|
|||||||
return Errno.InvalidArgument;
|
return Errno.InvalidArgument;
|
||||||
|
|
||||||
KeyValuePair<string, CompleteDirectoryEntry> dirent =
|
KeyValuePair<string, CompleteDirectoryEntry> dirent =
|
||||||
parent.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[pieces.Length - 1]);
|
parent.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[^1]);
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(dirent.Key))
|
if(string.IsNullOrEmpty(dirent.Key))
|
||||||
return Errno.NoSuchFile;
|
return Errno.NoSuchFile;
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ namespace Aaru.Filesystems.FATX
|
|||||||
return Errno.InvalidArgument;
|
return Errno.InvalidArgument;
|
||||||
|
|
||||||
KeyValuePair<string, DirectoryEntry> dirent =
|
KeyValuePair<string, DirectoryEntry> dirent =
|
||||||
parent.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[pieces.Length - 1]);
|
parent.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[^1]);
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(dirent.Key))
|
if(string.IsNullOrEmpty(dirent.Key))
|
||||||
return Errno.NoSuchFile;
|
return Errno.NoSuchFile;
|
||||||
|
|||||||
@@ -465,15 +465,15 @@ namespace Aaru.Filesystems.ISO9660
|
|||||||
return Errno.InvalidArgument;
|
return Errno.InvalidArgument;
|
||||||
|
|
||||||
KeyValuePair<string, DecodedDirectoryEntry> dirent =
|
KeyValuePair<string, DecodedDirectoryEntry> dirent =
|
||||||
parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[pieces.Length - 1]);
|
parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[^1]);
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(dirent.Key))
|
if(string.IsNullOrEmpty(dirent.Key))
|
||||||
{
|
{
|
||||||
if(!joliet &&
|
if(!joliet &&
|
||||||
!pieces[pieces.Length - 1].EndsWith(";1", StringComparison.Ordinal))
|
!pieces[^1].EndsWith(";1", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) ==
|
dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) ==
|
||||||
pieces[pieces.Length - 1] + ";1");
|
pieces[^1] + ";1");
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(dirent.Key))
|
if(string.IsNullOrEmpty(dirent.Key))
|
||||||
return Errno.NoSuchFile;
|
return Errno.NoSuchFile;
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ namespace Aaru.Filesystems
|
|||||||
return Errno.InvalidArgument;
|
return Errno.InvalidArgument;
|
||||||
|
|
||||||
KeyValuePair<string, DirectoryEntryWithPointers> dirent =
|
KeyValuePair<string, DirectoryEntryWithPointers> dirent =
|
||||||
parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[pieces.Length - 1]);
|
parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[^1]);
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(dirent.Key))
|
if(string.IsNullOrEmpty(dirent.Key))
|
||||||
return Errno.NoSuchFile;
|
return Errno.NoSuchFile;
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ namespace Aaru.Filters
|
|||||||
if(buffer.Length <= 512)
|
if(buffer.Length <= 512)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return buffer[buffer.Length - 512] != 0x6B || buffer[buffer.Length - 511] != 0x6F ||
|
return buffer[^512] != 0x6B || buffer[^511] != 0x6F || buffer[^510] != 0x6C || buffer[^509] != 0x79;
|
||||||
buffer[buffer.Length - 510] != 0x6C || buffer[buffer.Length - 509] != 0x79;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Identify(Stream stream)
|
public bool Identify(Stream stream)
|
||||||
|
|||||||
@@ -70,11 +70,9 @@ namespace Aaru.Filters
|
|||||||
|
|
||||||
public bool HasResourceFork() => false;
|
public bool HasResourceFork() => false;
|
||||||
|
|
||||||
public bool Identify(byte[] buffer) => buffer[0] == 0xFD && buffer[1] == 0x37 &&
|
public bool Identify(byte[] buffer) => buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A &&
|
||||||
buffer[2] == 0x7A &&
|
buffer[3] == 0x58 && buffer[4] == 0x5A && buffer[5] == 0x00 &&
|
||||||
buffer[3] == 0x58 && buffer[4] == 0x5A &&
|
buffer[^2] == 0x59 && buffer[^1] == 0x5A;
|
||||||
buffer[5] == 0x00 &&
|
|
||||||
buffer[buffer.Length - 2] == 0x59 && buffer[buffer.Length - 1] == 0x5A;
|
|
||||||
|
|
||||||
public bool Identify(Stream stream)
|
public bool Identify(Stream stream)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace Aaru.DiscImages
|
|||||||
imageInfo.DriveManufacturer = separated[0];
|
imageInfo.DriveManufacturer = separated[0];
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(imageInfo.DriveModel))
|
if(string.IsNullOrWhiteSpace(imageInfo.DriveModel))
|
||||||
imageInfo.DriveModel = separated[separated.Length - 1];
|
imageInfo.DriveModel = separated[^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision))
|
if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision))
|
||||||
|
|||||||
@@ -353,12 +353,16 @@ namespace Aaru.DiscImages
|
|||||||
}
|
}
|
||||||
else if(matchRedumpSdArea.Success)
|
else if(matchRedumpSdArea.Success)
|
||||||
{
|
{
|
||||||
AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM SINGLE-DENSITY AREA at line {0}", lineNumber);
|
AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM SINGLE-DENSITY AREA at line {0}",
|
||||||
|
lineNumber);
|
||||||
|
|
||||||
_discImage.IsRedumpGigadisc = true;
|
_discImage.IsRedumpGigadisc = true;
|
||||||
}
|
}
|
||||||
else if(matchRedumpHdArea.Success)
|
else if(matchRedumpHdArea.Success)
|
||||||
{
|
{
|
||||||
AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM HIGH-DENSITY AREA at line {0}", lineNumber);
|
AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM HIGH-DENSITY AREA at line {0}",
|
||||||
|
lineNumber);
|
||||||
|
|
||||||
_discImage.IsRedumpGigadisc = true;
|
_discImage.IsRedumpGigadisc = true;
|
||||||
currentSession = 2;
|
currentSession = 2;
|
||||||
}
|
}
|
||||||
@@ -500,7 +504,7 @@ namespace Aaru.DiscImages
|
|||||||
|
|
||||||
// Check if file path is quoted
|
// Check if file path is quoted
|
||||||
if(datafile[0] == '"' &&
|
if(datafile[0] == '"' &&
|
||||||
datafile[datafile.Length - 1] == '"')
|
datafile[^1] == '"')
|
||||||
datafile = datafile.Substring(1, datafile.Length - 2); // Unquote it
|
datafile = datafile.Substring(1, datafile.Length - 2); // Unquote it
|
||||||
|
|
||||||
currentFile.DataFilter = filtersList.GetFilter(datafile);
|
currentFile.DataFilter = filtersList.GetFilter(datafile);
|
||||||
@@ -805,6 +809,7 @@ namespace Aaru.DiscImages
|
|||||||
firstSessionTrk = i;
|
firstSessionTrk = i;
|
||||||
firstTrackRead = true;
|
firstTrackRead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionSectors += cueTracks[i].Sectors;
|
sessionSectors += cueTracks[i].Sectors;
|
||||||
|
|
||||||
if(i > lastSessionTrack)
|
if(i > lastSessionTrack)
|
||||||
@@ -836,7 +841,8 @@ namespace Aaru.DiscImages
|
|||||||
|
|
||||||
CdrWinTrack firstSessionTrack = cueTracks.OrderBy(t => t.Sequence).First(t => t.Session == s);
|
CdrWinTrack firstSessionTrack = cueTracks.OrderBy(t => t.Sequence).First(t => t.Session == s);
|
||||||
|
|
||||||
if (cueTracks.All(i => i.TrackFile.DataFilter.GetFilename() == cueTracks.First().TrackFile.DataFilter.GetFilename()))
|
if(cueTracks.All(i => i.TrackFile.DataFilter.GetFilename() ==
|
||||||
|
cueTracks.First().TrackFile.DataFilter.GetFilename()))
|
||||||
{
|
{
|
||||||
if(firstSessionTrack.Indexes.TryGetValue(0, out sessions[s - 1].StartSector))
|
if(firstSessionTrack.Indexes.TryGetValue(0, out sessions[s - 1].StartSector))
|
||||||
continue;
|
continue;
|
||||||
@@ -1208,6 +1214,7 @@ namespace Aaru.DiscImages
|
|||||||
|
|
||||||
else if(_discImage.IsRedumpGigadisc)
|
else if(_discImage.IsRedumpGigadisc)
|
||||||
_imageInfo.Application = "Redump.org";
|
_imageInfo.Application = "Redump.org";
|
||||||
|
|
||||||
// Detect ISOBuster extensions
|
// Detect ISOBuster extensions
|
||||||
else if(_discImage.OriginalMediaType != null ||
|
else if(_discImage.OriginalMediaType != null ||
|
||||||
_discImage.Comment.ToLower().Contains("isobuster") ||
|
_discImage.Comment.ToLower().Contains("isobuster") ||
|
||||||
@@ -1839,6 +1846,7 @@ namespace Aaru.DiscImages
|
|||||||
throw new ImageNotSupportedException("Session does not exist in disc image");
|
throw new ImageNotSupportedException("Session does not exist in disc image");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Track> GetSessionTracks(ushort session) => Tracks.Where(t => t.TrackSession == session).OrderBy(t => t.TrackSequence).ToList();
|
public List<Track> GetSessionTracks(ushort session) =>
|
||||||
|
Tracks.Where(t => t.TrackSession == session).OrderBy(t => t.TrackSequence).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ namespace Aaru.DiscImages
|
|||||||
{
|
{
|
||||||
byte[] tmpbuf = new byte[inbuf.Length + 1];
|
byte[] tmpbuf = new byte[inbuf.Length + 1];
|
||||||
Array.Copy(inbuf, 0, tmpbuf, 0, inbuf.Length);
|
Array.Copy(inbuf, 0, tmpbuf, 0, inbuf.Length);
|
||||||
tmpbuf[tmpbuf.Length - 1] = 0x20;
|
tmpbuf[^1] = 0x20;
|
||||||
inbuf = tmpbuf;
|
inbuf = tmpbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ namespace Aaru.Partitions
|
|||||||
byte[] bootSector = imagePlugin.ReadSector(0);
|
byte[] bootSector = imagePlugin.ReadSector(0);
|
||||||
byte[] sector = imagePlugin.ReadSector(1);
|
byte[] sector = imagePlugin.ReadSector(1);
|
||||||
|
|
||||||
if(bootSector[bootSector.Length - 2] != 0x55 ||
|
if(bootSector[^2] != 0x55 ||
|
||||||
bootSector[bootSector.Length - 1] != 0xAA)
|
bootSector[^1] != 0xAA)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Prevent false positives with some FAT BPBs
|
// Prevent false positives with some FAT BPBs
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ namespace Aaru.Commands.Media
|
|||||||
for(int t = 1; t < tracks.Length; t++)
|
for(int t = 1; t < tracks.Length; t++)
|
||||||
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
||||||
|
|
||||||
tracks[tracks.Length - 1].TrackEndSector = (ulong)lastSector;
|
tracks[^1].TrackEndSector = (ulong)lastSector;
|
||||||
|
|
||||||
AaruConsole.WriteLine();
|
AaruConsole.WriteLine();
|
||||||
AaruConsole.WriteLine("Track calculations:");
|
AaruConsole.WriteLine("Track calculations:");
|
||||||
|
|||||||
Reference in New Issue
Block a user