mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-30 21:27:24 -05:00
Use c#11 features
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace pkNX.Containers.VFS;
|
||||
|
||||
@@ -82,12 +80,12 @@ public bool Exists(FileSystemPath path)
|
||||
|
||||
public IFileSystem? GetFirstWhereExists(FileSystemPath path)
|
||||
{
|
||||
return _fileSystems.FirstOrDefault(fs => fs.Exists(path));
|
||||
return Array.Find(_fileSystems, fs => fs.Exists(path));
|
||||
}
|
||||
|
||||
public IFileSystem? GetFirstWritableWhereExists(FileSystemPath path)
|
||||
{
|
||||
return _fileSystems.FirstOrDefault(fs => !fs.IsReadOnly && fs.Exists(path));
|
||||
return Array.Find(_fileSystems, fs => !fs.IsReadOnly && fs.Exists(path));
|
||||
}
|
||||
|
||||
private bool ValidateOpenMode(FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read)
|
||||
@@ -115,10 +113,7 @@ public Stream OpenFile(FileSystemPath path, FileMode mode = FileMode.Open, FileA
|
||||
case FileMode.Open:
|
||||
{
|
||||
// just read from top layer
|
||||
IFileSystem? fs = GetFirstWhereExists(path);
|
||||
if (fs == null)
|
||||
throw new FileNotFoundException($"Could not find the file at the specified path: {path}", nameof(path));
|
||||
|
||||
var fs = GetFirstWhereExists(path) ?? throw new FileNotFoundException($"Could not find the file at the specified path: {path}", nameof(path));
|
||||
return fs.OpenFile(path, FileMode.Open, access);
|
||||
}
|
||||
case FileMode.OpenOrCreate:
|
||||
|
||||
Reference in New Issue
Block a user