mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-07 10:05:11 -05:00
Add VFS
This commit is contained in:
55
pkNX.Containers/VFS/FileSystems/ReadOnlyFileSystem.cs
Normal file
55
pkNX.Containers/VFS/FileSystems/ReadOnlyFileSystem.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace pkNX.Containers.VFS;
|
||||
|
||||
public class ReadOnlyFileSystem : IFileSystem
|
||||
{
|
||||
public bool IsReadOnly => true;
|
||||
|
||||
public IFileSystem FileSystem { get; }
|
||||
|
||||
public ReadOnlyFileSystem(IFileSystem fileSystem)
|
||||
{
|
||||
FileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
FileSystem.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public IEnumerable<FileSystemPath> GetEntities(FileSystemPath path)
|
||||
{
|
||||
return FileSystem.GetEntities(path);
|
||||
}
|
||||
|
||||
public bool Exists(FileSystemPath path)
|
||||
{
|
||||
return FileSystem.Exists(path);
|
||||
}
|
||||
|
||||
public Stream OpenFile(FileSystemPath path, FileAccess access)
|
||||
{
|
||||
if (access != FileAccess.Read)
|
||||
throw new InvalidOperationException("This is a read-only filesystem.");
|
||||
return FileSystem.OpenFile(path, access);
|
||||
}
|
||||
|
||||
public Stream CreateFile(FileSystemPath path)
|
||||
{
|
||||
throw new InvalidOperationException("This is a read-only filesystem.");
|
||||
}
|
||||
|
||||
public void CreateDirectory(FileSystemPath path)
|
||||
{
|
||||
throw new InvalidOperationException("This is a read-only filesystem.");
|
||||
}
|
||||
|
||||
public void Delete(FileSystemPath path)
|
||||
{
|
||||
throw new InvalidOperationException("This is a read-only filesystem.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user