mirror of
https://github.com/kwsch/pkNX.git
synced 2026-10-01 05:37:29 -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:
@@ -26,9 +26,29 @@ public string GetExtension()
|
||||
return Name[(lastPeriod + 1)..];
|
||||
}
|
||||
|
||||
public Stream Open(FileAccess access = FileAccess.Read)
|
||||
public Stream Open(FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read)
|
||||
{
|
||||
return FileSystem.OpenFile(Path, access);
|
||||
return FileSystem.OpenFile(Path, mode, access);
|
||||
}
|
||||
|
||||
public Stream OpenRead()
|
||||
{
|
||||
return FileSystem.OpenFile(Path, FileMode.Open, FileAccess.Read);
|
||||
}
|
||||
|
||||
public Stream OpenWrite()
|
||||
{
|
||||
return FileSystem.OpenWrite(Path);
|
||||
}
|
||||
|
||||
public void CopyTo(VirtualDirectory destination)
|
||||
{
|
||||
FileSystem.Copy(Path, destination.FileSystem, destination.Path.AppendFile(Name));
|
||||
}
|
||||
|
||||
public void MoveTo(VirtualDirectory destination)
|
||||
{
|
||||
FileSystem.Move(Path, destination.FileSystem, destination.Path.AppendFile(Name));
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> ReadAllBytes()
|
||||
@@ -57,13 +77,13 @@ public string ReadAllText()
|
||||
|
||||
public void WriteAllBytes(ReadOnlySpan<byte> bytes)
|
||||
{
|
||||
using var stream = Open(FileAccess.Write);
|
||||
using var stream = OpenWrite();
|
||||
stream.Write(bytes);
|
||||
}
|
||||
|
||||
public void WriteAllText(string text)
|
||||
{
|
||||
using var stream = Open(FileAccess.Write);
|
||||
using var stream = OpenWrite();
|
||||
using var writer = new StreamWriter(stream);
|
||||
writer.Write(text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user