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,8 +372,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
for(int t = 1; t < tracks.Length; t++)
|
||||
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
||||
|
||||
tracks[tracks.Length - 1].TrackEndSector = (ulong)lastSector;
|
||||
blocks = (ulong)(lastSector + 1);
|
||||
tracks[^1].TrackEndSector = (ulong)lastSector;
|
||||
blocks = (ulong)(lastSector + 1);
|
||||
|
||||
if(blocks == 0)
|
||||
{
|
||||
|
||||
@@ -834,7 +834,7 @@ namespace Aaru.Devices
|
||||
else
|
||||
{
|
||||
Manufacturer = separated[0];
|
||||
Model = separated[separated.Length - 1];
|
||||
Model = separated[^1];
|
||||
}
|
||||
|
||||
FirmwareRevision = ataid.Value.FirmwareRevision;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Aaru.Devices.FreeBSD
|
||||
else
|
||||
{
|
||||
deviceInfo.Vendor = separated[0];
|
||||
deviceInfo.Model = separated[separated.Length - 1];
|
||||
deviceInfo.Model = separated[^1];
|
||||
}
|
||||
|
||||
deviceInfo.Serial = idt.Value.SerialNumber;
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace Aaru.Filesystems.FAT
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
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))
|
||||
return Errno.NoSuchFile;
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Aaru.Filesystems.FATX
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
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))
|
||||
return Errno.NoSuchFile;
|
||||
|
||||
@@ -465,15 +465,15 @@ namespace Aaru.Filesystems.ISO9660
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
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(!joliet &&
|
||||
!pieces[pieces.Length - 1].EndsWith(";1", StringComparison.Ordinal))
|
||||
!pieces[^1].EndsWith(";1", StringComparison.Ordinal))
|
||||
{
|
||||
dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) ==
|
||||
pieces[pieces.Length - 1] + ";1");
|
||||
pieces[^1] + ";1");
|
||||
|
||||
if(string.IsNullOrEmpty(dirent.Key))
|
||||
return Errno.NoSuchFile;
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Aaru.Filesystems
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
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))
|
||||
return Errno.NoSuchFile;
|
||||
|
||||
@@ -83,8 +83,7 @@ namespace Aaru.Filters
|
||||
if(buffer.Length <= 512)
|
||||
return true;
|
||||
|
||||
return buffer[buffer.Length - 512] != 0x6B || buffer[buffer.Length - 511] != 0x6F ||
|
||||
buffer[buffer.Length - 510] != 0x6C || buffer[buffer.Length - 509] != 0x79;
|
||||
return buffer[^512] != 0x6B || buffer[^511] != 0x6F || buffer[^510] != 0x6C || buffer[^509] != 0x79;
|
||||
}
|
||||
|
||||
public bool Identify(Stream stream)
|
||||
|
||||
@@ -70,11 +70,9 @@ namespace Aaru.Filters
|
||||
|
||||
public bool HasResourceFork() => false;
|
||||
|
||||
public bool Identify(byte[] buffer) => buffer[0] == 0xFD && buffer[1] == 0x37 &&
|
||||
buffer[2] == 0x7A &&
|
||||
buffer[3] == 0x58 && buffer[4] == 0x5A &&
|
||||
buffer[5] == 0x00 &&
|
||||
buffer[buffer.Length - 2] == 0x59 && buffer[buffer.Length - 1] == 0x5A;
|
||||
public bool Identify(byte[] buffer) => buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A &&
|
||||
buffer[3] == 0x58 && buffer[4] == 0x5A && buffer[5] == 0x00 &&
|
||||
buffer[^2] == 0x59 && buffer[^1] == 0x5A;
|
||||
|
||||
public bool Identify(Stream stream)
|
||||
{
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Aaru.DiscImages
|
||||
imageInfo.DriveManufacturer = separated[0];
|
||||
|
||||
if(string.IsNullOrWhiteSpace(imageInfo.DriveModel))
|
||||
imageInfo.DriveModel = separated[separated.Length - 1];
|
||||
imageInfo.DriveModel = separated[^1];
|
||||
}
|
||||
|
||||
if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision))
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Aaru.DiscImages
|
||||
bool inTruripTrackHash = false;
|
||||
|
||||
ulong gdRomSession2Offset = 45000;
|
||||
densitySeparationSectors = 0;
|
||||
densitySeparationSectors = 0;
|
||||
|
||||
while(_cueStream.Peek() >= 0)
|
||||
{
|
||||
@@ -353,14 +353,18 @@ namespace Aaru.DiscImages
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
currentSession = 2;
|
||||
currentSession = 2;
|
||||
}
|
||||
else if(matchLba.Success)
|
||||
AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM MSF at line {0}", lineNumber);
|
||||
@@ -499,8 +503,8 @@ namespace Aaru.DiscImages
|
||||
currentFile.FileType = matchFile.Groups[2].Value;
|
||||
|
||||
// Check if file path is quoted
|
||||
if(datafile[0] == '"' &&
|
||||
datafile[datafile.Length - 1] == '"')
|
||||
if(datafile[0] == '"' &&
|
||||
datafile[^1] == '"')
|
||||
datafile = datafile.Substring(1, datafile.Length - 2); // Unquote it
|
||||
|
||||
currentFile.DataFilter = filtersList.GetFilter(datafile);
|
||||
@@ -803,8 +807,9 @@ namespace Aaru.DiscImages
|
||||
if(!firstTrackRead)
|
||||
{
|
||||
firstSessionTrk = i;
|
||||
firstTrackRead = true;
|
||||
firstTrackRead = true;
|
||||
}
|
||||
|
||||
sessionSectors += cueTracks[i].Sectors;
|
||||
|
||||
if(i > lastSessionTrack)
|
||||
@@ -832,11 +837,12 @@ namespace Aaru.DiscImages
|
||||
cueTracks[lastSessionTrack].Sectors = leadout - startSector;
|
||||
}
|
||||
else
|
||||
sessions[s - 1].EndSector = (sessions[s -1].StartSector + sessionSectors) - 1;
|
||||
sessions[s - 1].EndSector = (sessions[s - 1].StartSector + sessionSectors) - 1;
|
||||
|
||||
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))
|
||||
continue;
|
||||
@@ -1121,9 +1127,9 @@ namespace Aaru.DiscImages
|
||||
if(!_discImage.Tracks[i].Indexes.TryGetValue(1, out ulong _))
|
||||
throw new ImageNotSupportedException($"Track {_discImage.Tracks[i].Sequence} lacks index 01");
|
||||
|
||||
if(_discImage.IsRedumpGigadisc &&
|
||||
if(_discImage.IsRedumpGigadisc &&
|
||||
_discImage.Tracks[i].Session != 1 &&
|
||||
sectorOffset < gdRomSession2Offset)
|
||||
sectorOffset < gdRomSession2Offset)
|
||||
{
|
||||
_offsetMap.Add(0, sectorOffset);
|
||||
densitySeparationSectors = gdRomSession2Offset - sectorOffset;
|
||||
@@ -1208,6 +1214,7 @@ namespace Aaru.DiscImages
|
||||
|
||||
else if(_discImage.IsRedumpGigadisc)
|
||||
_imageInfo.Application = "Redump.org";
|
||||
|
||||
// Detect ISOBuster extensions
|
||||
else if(_discImage.OriginalMediaType != null ||
|
||||
_discImage.Comment.ToLower().Contains("isobuster") ||
|
||||
@@ -1839,6 +1846,7 @@ namespace Aaru.DiscImages
|
||||
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,8 +45,8 @@ namespace Aaru.DiscImages
|
||||
{
|
||||
byte[] tmpbuf = new byte[inbuf.Length + 1];
|
||||
Array.Copy(inbuf, 0, tmpbuf, 0, inbuf.Length);
|
||||
tmpbuf[tmpbuf.Length - 1] = 0x20;
|
||||
inbuf = tmpbuf;
|
||||
tmpbuf[^1] = 0x20;
|
||||
inbuf = tmpbuf;
|
||||
}
|
||||
|
||||
byte[] outbuf = new byte[inbuf.Length];
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Aaru.Partitions
|
||||
byte[] bootSector = imagePlugin.ReadSector(0);
|
||||
byte[] sector = imagePlugin.ReadSector(1);
|
||||
|
||||
if(bootSector[bootSector.Length - 2] != 0x55 ||
|
||||
bootSector[bootSector.Length - 1] != 0xAA)
|
||||
if(bootSector[^2] != 0x55 ||
|
||||
bootSector[^1] != 0xAA)
|
||||
return false;
|
||||
|
||||
// Prevent false positives with some FAT BPBs
|
||||
|
||||
@@ -568,7 +568,7 @@ namespace Aaru.Commands.Media
|
||||
for(int t = 1; t < tracks.Length; t++)
|
||||
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
||||
|
||||
tracks[tracks.Length - 1].TrackEndSector = (ulong)lastSector;
|
||||
tracks[^1].TrackEndSector = (ulong)lastSector;
|
||||
|
||||
AaruConsole.WriteLine();
|
||||
AaruConsole.WriteLine("Track calculations:");
|
||||
|
||||
Reference in New Issue
Block a user