mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use range indexers.
This commit is contained in:
@@ -379,10 +379,10 @@ public sealed class ErrorLog
|
|||||||
if(prettySense != null)
|
if(prettySense != null)
|
||||||
{
|
{
|
||||||
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
||||||
prettySense = prettySense.Substring(12);
|
prettySense = prettySense[12..];
|
||||||
|
|
||||||
if(prettySense.EndsWith('\n'))
|
if(prettySense.EndsWith('\n'))
|
||||||
prettySense = prettySense.Substring(0, prettySense.Length - 1);
|
prettySense = prettySense[..^1];
|
||||||
|
|
||||||
prettySense = prettySense.Replace("\n", " - ");
|
prettySense = prettySense.Replace("\n", " - ");
|
||||||
|
|
||||||
@@ -400,10 +400,10 @@ public sealed class ErrorLog
|
|||||||
if(prettySense != null)
|
if(prettySense != null)
|
||||||
{
|
{
|
||||||
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
||||||
prettySense = prettySense.Substring(12);
|
prettySense = prettySense[12..];
|
||||||
|
|
||||||
if(prettySense.EndsWith('\n'))
|
if(prettySense.EndsWith('\n'))
|
||||||
prettySense = prettySense.Substring(0, prettySense.Length - 1);
|
prettySense = prettySense[..^1];
|
||||||
|
|
||||||
prettySense = prettySense.Replace("\n", " - ");
|
prettySense = prettySense.Replace("\n", " - ");
|
||||||
|
|
||||||
@@ -443,10 +443,10 @@ public sealed class ErrorLog
|
|||||||
if(prettySense != null)
|
if(prettySense != null)
|
||||||
{
|
{
|
||||||
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
||||||
prettySense = prettySense.Substring(12);
|
prettySense = prettySense[12..];
|
||||||
|
|
||||||
if(prettySense.EndsWith('\n'))
|
if(prettySense.EndsWith('\n'))
|
||||||
prettySense = prettySense.Substring(0, prettySense.Length - 1);
|
prettySense = prettySense[..^1];
|
||||||
|
|
||||||
prettySense = prettySense.Replace("\n", " - ");
|
prettySense = prettySense.Replace("\n", " - ");
|
||||||
|
|
||||||
@@ -464,10 +464,10 @@ public sealed class ErrorLog
|
|||||||
if(prettySense != null)
|
if(prettySense != null)
|
||||||
{
|
{
|
||||||
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal))
|
||||||
prettySense = prettySense.Substring(12);
|
prettySense = prettySense[12..];
|
||||||
|
|
||||||
if(prettySense.EndsWith('\n'))
|
if(prettySense.EndsWith('\n'))
|
||||||
prettySense = prettySense.Substring(0, prettySense.Length - 1);
|
prettySense = prettySense[..^1];
|
||||||
|
|
||||||
prettySense = prettySense.Replace("\n", " - ");
|
prettySense = prettySense.Replace("\n", " - ");
|
||||||
|
|
||||||
|
|||||||
@@ -1288,7 +1288,7 @@ public static class MMC
|
|||||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||||
|
|
||||||
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
||||||
name = name.Substring(0, name.Length - 2);
|
name = name[..^2];
|
||||||
|
|
||||||
if(name == "PHOTO_CD" &&
|
if(name == "PHOTO_CD" &&
|
||||||
(isoSector[rootPos + 25] & 0x02) == 0x02)
|
(isoSector[rootPos + 25] & 0x02) == 0x02)
|
||||||
@@ -1342,7 +1342,7 @@ public static class MMC
|
|||||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||||
|
|
||||||
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
||||||
name = name.Substring(0, name.Length - 2);
|
name = name[..^2];
|
||||||
|
|
||||||
if(name == "INFO.PCD")
|
if(name == "INFO.PCD")
|
||||||
{
|
{
|
||||||
@@ -1775,7 +1775,7 @@ public static class MMC
|
|||||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||||
|
|
||||||
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
||||||
name = name.Substring(0, name.Length - 2);
|
name = name[..^2];
|
||||||
|
|
||||||
rootEntries.Add(name);
|
rootEntries.Add(name);
|
||||||
|
|
||||||
@@ -2020,7 +2020,7 @@ public static class MMC
|
|||||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||||
|
|
||||||
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
||||||
name = name.Substring(0, name.Length - 2);
|
name = name[..^2];
|
||||||
|
|
||||||
if(name is "INFO.VCD" or "INFO.SVD")
|
if(name is "INFO.VCD" or "INFO.SVD")
|
||||||
{
|
{
|
||||||
@@ -2116,7 +2116,7 @@ public static class MMC
|
|||||||
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
string name = StringHandlers.CToString(tmpName).ToUpperInvariant();
|
||||||
|
|
||||||
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
if(name.EndsWith(";1", StringComparison.InvariantCulture))
|
||||||
name = name.Substring(0, name.Length - 2);
|
name = name[..^2];
|
||||||
|
|
||||||
if(name == "INFO.PCD")
|
if(name == "INFO.PCD")
|
||||||
{
|
{
|
||||||
@@ -2210,13 +2210,13 @@ public static class MMC
|
|||||||
|
|
||||||
if(line.StartsWith("BOOT=cdrom:", StringComparison.InvariantCultureIgnoreCase))
|
if(line.StartsWith("BOOT=cdrom:", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
ps1BootFile = line.Substring(11);
|
ps1BootFile = line[11..];
|
||||||
|
|
||||||
if(ps1BootFile.StartsWith('\\'))
|
if(ps1BootFile.StartsWith('\\'))
|
||||||
ps1BootFile = ps1BootFile.Substring(1);
|
ps1BootFile = ps1BootFile[1..];
|
||||||
|
|
||||||
if(ps1BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase))
|
if(ps1BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase))
|
||||||
ps1BootFile = ps1BootFile.Substring(0, ps1BootFile.Length - 2);
|
ps1BootFile = ps1BootFile[..^2];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2224,13 +2224,13 @@ public static class MMC
|
|||||||
if(!line.StartsWith("BOOT2=cdrom0:", StringComparison.InvariantCultureIgnoreCase))
|
if(!line.StartsWith("BOOT2=cdrom0:", StringComparison.InvariantCultureIgnoreCase))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ps2BootFile = line.Substring(13);
|
ps2BootFile = line[13..];
|
||||||
|
|
||||||
if(ps2BootFile.StartsWith('\\'))
|
if(ps2BootFile.StartsWith('\\'))
|
||||||
ps2BootFile = ps2BootFile.Substring(1);
|
ps2BootFile = ps2BootFile[1..];
|
||||||
|
|
||||||
if(ps2BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase))
|
if(ps2BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase))
|
||||||
ps2BootFile = ps2BootFile.Substring(0, ps2BootFile.Length - 2);
|
ps2BootFile = ps2BootFile[..^2];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ namespace Aaru.Devices.Linux;
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
[System.Runtime.Versioning.SupportedOSPlatform("linux")]
|
[SupportedOSPlatform("linux")]
|
||||||
static class ListDevices
|
static class ListDevices
|
||||||
{
|
{
|
||||||
const string PATH_SYS_DEVBLOCK = "/sys/block/";
|
const string PATH_SYS_DEVBLOCK = "/sys/block/";
|
||||||
@@ -124,7 +125,7 @@ static class ListDevices
|
|||||||
if(pieces.Length > 1)
|
if(pieces.Length > 1)
|
||||||
{
|
{
|
||||||
devices[i].Vendor = pieces[0];
|
devices[i].Vendor = pieces[0];
|
||||||
devices[i].Model = devices[i].Model.Substring(pieces[0].Length + 1);
|
devices[i].Model = devices[i].Model[(pieces[0].Length + 1)..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,13 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Aaru.Helpers;
|
using Aaru.Helpers;
|
||||||
using Microsoft.Win32.SafeHandles;
|
using Microsoft.Win32.SafeHandles;
|
||||||
using Marshal = System.Runtime.InteropServices.Marshal;
|
using Marshal = System.Runtime.InteropServices.Marshal;
|
||||||
|
|
||||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
static class ListDevices
|
static class ListDevices
|
||||||
{
|
{
|
||||||
/// <summary>Converts a hex dump string to the ASCII string it represents</summary>
|
/// <summary>Converts a hex dump string to the ASCII string it represents</summary>
|
||||||
@@ -189,7 +190,7 @@ static class ListDevices
|
|||||||
if(pieces?.Length > 1)
|
if(pieces?.Length > 1)
|
||||||
{
|
{
|
||||||
info.Vendor = pieces[0];
|
info.Vendor = pieces[0];
|
||||||
info.Model = info.Model.Substring(pieces[0].Length + 1);
|
info.Model = info.Model[(pieces[0].Length + 1)..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public sealed partial class FAT
|
|||||||
return ErrorNumber.NoError;
|
return ErrorNumber.NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
string cutPath = path.StartsWith("/", StringComparison.Ordinal) ? path.Substring(1).ToLower(_cultureInfo)
|
string cutPath = path.StartsWith("/", StringComparison.Ordinal) ? path[1..].ToLower(_cultureInfo)
|
||||||
: path.ToLower(_cultureInfo);
|
: path.ToLower(_cultureInfo);
|
||||||
|
|
||||||
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, CompleteDirectoryEntry> currentDirectory))
|
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, CompleteDirectoryEntry> currentDirectory))
|
||||||
@@ -366,9 +366,8 @@ public sealed partial class FAT
|
|||||||
foreach(KeyValuePair<string, CompleteDirectoryEntry> sidecar in fat32EaSidecars)
|
foreach(KeyValuePair<string, CompleteDirectoryEntry> sidecar in fat32EaSidecars)
|
||||||
{
|
{
|
||||||
// No real file this sidecar accompanies
|
// No real file this sidecar accompanies
|
||||||
if(!currentDirectory.
|
if(!currentDirectory.TryGetValue(sidecar.Key[..^FAT32_EA_TAIL.Length],
|
||||||
TryGetValue(sidecar.Key.Substring(0, sidecar.Key.Length - FAT32_EA_TAIL.Length),
|
out CompleteDirectoryEntry fileWithEa))
|
||||||
out CompleteDirectoryEntry fileWithEa))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If not in debug mode we will consider the lack of EA bitflags to mean the EAs are corrupted or not real
|
// If not in debug mode we will consider the lack of EA bitflags to mean the EAs are corrupted or not real
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ public sealed partial class FAT
|
|||||||
{
|
{
|
||||||
entry = null;
|
entry = null;
|
||||||
|
|
||||||
string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
|
string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
|
||||||
|
|
||||||
string[] pieces = cutPath.Split(new[]
|
string[] pieces = cutPath.Split(new[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1050,7 +1050,7 @@ public sealed partial class FAT
|
|||||||
foreach(KeyValuePair<string, CompleteDirectoryEntry> sidecar in fat32EaSidecars)
|
foreach(KeyValuePair<string, CompleteDirectoryEntry> sidecar in fat32EaSidecars)
|
||||||
{
|
{
|
||||||
// No real file this sidecar accompanies
|
// No real file this sidecar accompanies
|
||||||
if(!_rootDirectoryCache.TryGetValue(sidecar.Key.Substring(0, sidecar.Key.Length - FAT32_EA_TAIL.Length),
|
if(!_rootDirectoryCache.TryGetValue(sidecar.Key[..^FAT32_EA_TAIL.Length],
|
||||||
out CompleteDirectoryEntry fileWithEa))
|
out CompleteDirectoryEntry fileWithEa))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public sealed partial class FAT
|
|||||||
return ErrorNumber.NotSupported;
|
return ErrorNumber.NotSupported;
|
||||||
|
|
||||||
if(path[0] == '/')
|
if(path[0] == '/')
|
||||||
path = path.Substring(1);
|
path = path[1..];
|
||||||
|
|
||||||
if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary<string, byte[]> eas))
|
if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary<string, byte[]> eas))
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ public sealed partial class FAT
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
if(path[0] == '/')
|
if(path[0] == '/')
|
||||||
path = path.Substring(1);
|
path = path[1..];
|
||||||
|
|
||||||
if(!xattrs.Contains(xattr.ToLower(_cultureInfo)))
|
if(!xattrs.Contains(xattr.ToLower(_cultureInfo)))
|
||||||
return ErrorNumber.NoSuchExtendedAttribute;
|
return ErrorNumber.NoSuchExtendedAttribute;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public sealed partial class XboxFatPlugin
|
|||||||
return ErrorNumber.NoError;
|
return ErrorNumber.NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
|
string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
|
||||||
|
|
||||||
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DirectoryEntry> currentDirectory))
|
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DirectoryEntry> currentDirectory))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ public sealed partial class XboxFatPlugin
|
|||||||
{
|
{
|
||||||
entry = new DirectoryEntry();
|
entry = new DirectoryEntry();
|
||||||
|
|
||||||
string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
|
string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo);
|
||||||
|
|
||||||
string[] pieces = cutPath.Split(new[]
|
string[] pieces = cutPath.Split(new[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public sealed partial class ISO9660
|
|||||||
}
|
}
|
||||||
|
|
||||||
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
||||||
? path.Substring(1).ToLower(CultureInfo.CurrentUICulture)
|
? path[1..].ToLower(CultureInfo.CurrentUICulture)
|
||||||
: path.ToLower(CultureInfo.CurrentUICulture);
|
: path.ToLower(CultureInfo.CurrentUICulture);
|
||||||
|
|
||||||
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DecodedDirectoryEntry> currentDirectory))
|
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DecodedDirectoryEntry> currentDirectory))
|
||||||
@@ -142,8 +142,8 @@ public sealed partial class ISO9660
|
|||||||
switch(_namespace)
|
switch(_namespace)
|
||||||
{
|
{
|
||||||
case Namespace.Normal:
|
case Namespace.Normal:
|
||||||
contents.Add(entry.Filename.EndsWith(";1", StringComparison.Ordinal)
|
contents.Add(entry.Filename.EndsWith(";1", StringComparison.Ordinal) ? entry.Filename[..^2]
|
||||||
? entry.Filename.Substring(0, entry.Filename.Length - 2) : entry.Filename);
|
: entry.Filename);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Namespace.Vms:
|
case Namespace.Vms:
|
||||||
@@ -383,14 +383,14 @@ public sealed partial class ISO9660
|
|||||||
|
|
||||||
// Tailing '.' is only allowed on RRIP. If present it will be recreated below with the alternate name
|
// Tailing '.' is only allowed on RRIP. If present it will be recreated below with the alternate name
|
||||||
if(entry.Filename.EndsWith(".", StringComparison.Ordinal))
|
if(entry.Filename.EndsWith(".", StringComparison.Ordinal))
|
||||||
entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 1);
|
entry.Filename = entry.Filename[..^1];
|
||||||
|
|
||||||
if(entry.Filename.EndsWith(".;1", StringComparison.Ordinal))
|
if(entry.Filename.EndsWith(".;1", StringComparison.Ordinal))
|
||||||
entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 3) + ";1";
|
entry.Filename = entry.Filename[..^3] + ";1";
|
||||||
|
|
||||||
// This is a legal Joliet name, different from VMS version fields, but Nero MAX incorrectly creates these filenames
|
// This is a legal Joliet name, different from VMS version fields, but Nero MAX incorrectly creates these filenames
|
||||||
if(_joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal))
|
if(_joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal))
|
||||||
entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 2);
|
entry.Filename = entry.Filename[..^2];
|
||||||
|
|
||||||
int systemAreaStart = entryOff + record.name_len + _directoryRecordSize;
|
int systemAreaStart = entryOff + record.name_len + _directoryRecordSize;
|
||||||
int systemAreaLength = record.length - record.name_len - _directoryRecordSize;
|
int systemAreaLength = record.length - record.name_len - _directoryRecordSize;
|
||||||
@@ -502,16 +502,16 @@ public sealed partial class ISO9660
|
|||||||
while(line != null)
|
while(line != null)
|
||||||
{
|
{
|
||||||
// Skip the type field and the first space
|
// Skip the type field and the first space
|
||||||
string cutLine = line.Substring(2);
|
string cutLine = line[2..];
|
||||||
int spaceIndex = cutLine.IndexOf(' ');
|
int spaceIndex = cutLine.IndexOf(' ');
|
||||||
string originalName = cutLine.Substring(0, spaceIndex);
|
string originalName = cutLine[..spaceIndex];
|
||||||
string originalNameWithVersion;
|
string originalNameWithVersion;
|
||||||
string newName = cutLine.Substring(spaceIndex + 1).TrimStart();
|
string newName = cutLine[(spaceIndex + 1)..].TrimStart();
|
||||||
|
|
||||||
if(originalName.EndsWith(";1", StringComparison.Ordinal))
|
if(originalName.EndsWith(";1", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
originalNameWithVersion = originalName.ToLower(CultureInfo.CurrentUICulture);
|
originalNameWithVersion = originalName.ToLower(CultureInfo.CurrentUICulture);
|
||||||
originalName = originalNameWithVersion.Substring(0, originalName.Length - 2);
|
originalName = originalNameWithVersion[..(originalName.Length - 2)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1040,7 +1040,7 @@ public sealed partial class ISO9660
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
||||||
? path.Substring(1).ToLower(CultureInfo.CurrentUICulture)
|
? path[1..].ToLower(CultureInfo.CurrentUICulture)
|
||||||
: path.ToLower(CultureInfo.CurrentUICulture);
|
: path.ToLower(CultureInfo.CurrentUICulture);
|
||||||
|
|
||||||
string[] pieces = cutPath.Split(new[]
|
string[] pieces = cutPath.Split(new[]
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ public sealed partial class ISO9660
|
|||||||
entry = null;
|
entry = null;
|
||||||
|
|
||||||
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
||||||
? path.Substring(1).ToLower(CultureInfo.CurrentUICulture)
|
? path[1..].ToLower(CultureInfo.CurrentUICulture)
|
||||||
: path.ToLower(CultureInfo.CurrentUICulture);
|
: path.ToLower(CultureInfo.CurrentUICulture);
|
||||||
|
|
||||||
string[] pieces = cutPath.Split(new[]
|
string[] pieces = cutPath.Split(new[]
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public sealed partial class ISO9660
|
|||||||
|
|
||||||
bootSpec = "Unknown";
|
bootSpec = "Unknown";
|
||||||
|
|
||||||
if(Encoding.GetString(bvd.Value.system_id).Substring(0, 23) == "EL TORITO SPECIFICATION")
|
if(Encoding.GetString(bvd.Value.system_id)[..23] == "EL TORITO SPECIFICATION")
|
||||||
{
|
{
|
||||||
bootSpec = "El Torito";
|
bootSpec = "El Torito";
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public sealed partial class OperaFS
|
|||||||
}
|
}
|
||||||
|
|
||||||
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
||||||
? path.Substring(1).ToLower(CultureInfo.CurrentUICulture)
|
? path[1..].ToLower(CultureInfo.CurrentUICulture)
|
||||||
: path.ToLower(CultureInfo.CurrentUICulture);
|
: path.ToLower(CultureInfo.CurrentUICulture);
|
||||||
|
|
||||||
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DirectoryEntryWithPointers> currentDirectory))
|
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DirectoryEntryWithPointers> currentDirectory))
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public sealed partial class OperaFS
|
|||||||
entry = null;
|
entry = null;
|
||||||
|
|
||||||
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
|
||||||
? path.Substring(1).ToLower(CultureInfo.CurrentUICulture)
|
? path[1..].ToLower(CultureInfo.CurrentUICulture)
|
||||||
: path.ToLower(CultureInfo.CurrentUICulture);
|
: path.ToLower(CultureInfo.CurrentUICulture);
|
||||||
|
|
||||||
string[] pieces = cutPath.Split(new[]
|
string[] pieces = cutPath.Split(new[]
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public sealed class PCFX : IFilesystem
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
date = Encoding.GetString(header.date);
|
date = Encoding.GetString(header.date);
|
||||||
var year = int.Parse(date.Substring(0, 4));
|
var year = int.Parse(date[..4]);
|
||||||
var month = int.Parse(date.Substring(4, 2));
|
var month = int.Parse(date.Substring(4, 2));
|
||||||
var day = int.Parse(date.Substring(6, 2));
|
var day = int.Parse(date.Substring(6, 2));
|
||||||
dateTime = new DateTime(year, month, day);
|
dateTime = new DateTime(year, month, day);
|
||||||
|
|||||||
@@ -211,10 +211,10 @@ public class BZip2 : IFilter
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(BasePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true)
|
if(BasePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true)
|
||||||
return BasePath.Substring(0, BasePath.Length - 4);
|
return BasePath[..^4];
|
||||||
|
|
||||||
return BasePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true
|
return BasePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^6]
|
||||||
? BasePath.Substring(0, BasePath.Length - 6) : BasePath;
|
: BasePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,10 +210,10 @@ public sealed class GZip : IFilter
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(BasePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true)
|
if(BasePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true)
|
||||||
return BasePath.Substring(0, BasePath.Length - 3);
|
return BasePath[..^3];
|
||||||
|
|
||||||
return BasePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true
|
return BasePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5]
|
||||||
? BasePath.Substring(0, BasePath.Length - 5) : BasePath;
|
: BasePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,10 +179,10 @@ public sealed class LZip : IFilter
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(BasePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true)
|
if(BasePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true)
|
||||||
return BasePath.Substring(0, BasePath.Length - 3);
|
return BasePath[..^3];
|
||||||
|
|
||||||
return BasePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true
|
return BasePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5]
|
||||||
? BasePath.Substring(0, BasePath.Length - 5) : BasePath;
|
: BasePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,10 +184,10 @@ public sealed class XZ : IFilter
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(BasePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true)
|
if(BasePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true)
|
||||||
return BasePath.Substring(0, BasePath.Length - 3);
|
return BasePath[..^3];
|
||||||
|
|
||||||
return BasePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true
|
return BasePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5]
|
||||||
? BasePath.Substring(0, BasePath.Length - 5) : BasePath;
|
: BasePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ public sealed partial class ZZZRawImage
|
|||||||
|
|
||||||
// Search for known tags
|
// Search for known tags
|
||||||
string basename = imageFilter.BasePath;
|
string basename = imageFilter.BasePath;
|
||||||
basename = basename.Substring(0, basename.Length - _extension.Length);
|
basename = basename[..^_extension.Length];
|
||||||
|
|
||||||
_mediaTags = new Dictionary<MediaTagType, byte[]>();
|
_mediaTags = new Dictionary<MediaTagType, byte[]>();
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public sealed class Plan9 : IPartition
|
|||||||
// While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
|
// While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
|
||||||
string[] really = StringHandlers.CToString(sector).Split('\n');
|
string[] really = StringHandlers.CToString(sector).Split('\n');
|
||||||
|
|
||||||
foreach(string[] tokens in really.TakeWhile(part => part.Length >= 5 && part.Substring(0, 5) == "part ").
|
foreach(string[] tokens in really.TakeWhile(part => part.Length >= 5 && part[..5] == "part ").
|
||||||
Select(part => part.Split(' ')).TakeWhile(tokens => tokens.Length == 4))
|
Select(part => part.Split(' ')).TakeWhile(tokens => tokens.Length == 4))
|
||||||
{
|
{
|
||||||
if(!ulong.TryParse(tokens[2], out ulong start) ||
|
if(!ulong.TryParse(tokens[2], out ulong start) ||
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ sealed class LsCommand : Command
|
|||||||
List<string> directory = new();
|
List<string> directory = new();
|
||||||
|
|
||||||
if(path.StartsWith('/'))
|
if(path.StartsWith('/'))
|
||||||
path = path.Substring(1);
|
path = path[1..];
|
||||||
|
|
||||||
AaruConsole.WriteLine(string.IsNullOrEmpty(path) ? "Root directory" : $"Directory: {Markup.Escape(path)}");
|
AaruConsole.WriteLine(string.IsNullOrEmpty(path) ? "Root directory" : $"Directory: {Markup.Escape(path)}");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user