mirror of
https://github.com/kwsch/pkNX.git
synced 2026-10-02 14:16:55 -05:00
Made VFS fully functional
Still need to start using it, but want to do it a bit slow to test it out. Also should really build some unit tests for this one..
This commit is contained in:
@@ -30,12 +30,15 @@ public MountPoint(FileSystemPath mountPath, IFileSystem fileSystem)
|
||||
|
||||
public class VirtualFileSystem : IFileSystem
|
||||
{
|
||||
public static VirtualFileSystem Current { get; private set; } = null!;
|
||||
|
||||
public SortedSet<MountPoint> Mounts { get; }
|
||||
public bool IsReadOnly => Mounts.All(x => x.FileSystem.IsReadOnly);
|
||||
|
||||
public VirtualFileSystem(IEnumerable<MountPoint> mounts)
|
||||
{
|
||||
Mounts = new SortedSet<MountPoint>(mounts);
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public VirtualFileSystem(params MountPoint[] mounts) :
|
||||
@@ -84,18 +87,17 @@ public bool Exists(FileSystemPath path)
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Stream CreateFile(FileSystemPath path)
|
||||
public Stream OpenFile(FileSystemPath path, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read)
|
||||
{
|
||||
var mount = GetMountPoint(path);
|
||||
return mount.FileSystem.CreateFile(path);
|
||||
return mount.FileSystem.OpenFile(path, mode, access);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Stream OpenFile(FileSystemPath path, FileAccess access)
|
||||
{
|
||||
var mount = GetMountPoint(path);
|
||||
return mount.FileSystem.OpenFile(path, access);
|
||||
}
|
||||
public Stream OpenWrite(FileSystemPath path) => OpenFile(path, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Stream CreateFile(FileSystemPath path) => OpenFile(path, FileMode.Create, FileAccess.Write);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateDirectory(FileSystemPath path)
|
||||
|
||||
Reference in New Issue
Block a user