Use range indexers.

This commit is contained in:
2022-11-14 01:15:06 +00:00
parent e0508f096c
commit 6a4dea75ea
23 changed files with 65 additions and 64 deletions

View File

@@ -73,7 +73,7 @@ public sealed partial class FAT
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);
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)
{
// No real file this sidecar accompanies
if(!currentDirectory.
TryGetValue(sidecar.Key.Substring(0, sidecar.Key.Length - FAT32_EA_TAIL.Length),
out CompleteDirectoryEntry fileWithEa))
if(!currentDirectory.TryGetValue(sidecar.Key[..^FAT32_EA_TAIL.Length],
out CompleteDirectoryEntry fileWithEa))
continue;
// If not in debug mode we will consider the lack of EA bitflags to mean the EAs are corrupted or not real

View File

@@ -293,7 +293,7 @@ public sealed partial class FAT
{
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[]
{

View File

@@ -1050,7 +1050,7 @@ public sealed partial class FAT
foreach(KeyValuePair<string, CompleteDirectoryEntry> sidecar in fat32EaSidecars)
{
// 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))
continue;

View File

@@ -58,7 +58,7 @@ public sealed partial class FAT
return ErrorNumber.NotSupported;
if(path[0] == '/')
path = path.Substring(1);
path = path[1..];
if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary<string, byte[]> eas))
{
@@ -111,7 +111,7 @@ public sealed partial class FAT
return err;
if(path[0] == '/')
path = path.Substring(1);
path = path[1..];
if(!xattrs.Contains(xattr.ToLower(_cultureInfo)))
return ErrorNumber.NoSuchExtendedAttribute;