mirror of
https://github.com/kwsch/pkNX.git
synced 2026-08-28 05:14:18 -05:00
temp
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace pkNX.Containers.VFS;
|
||||
|
||||
public interface IFileSystem : IDisposable
|
||||
{
|
||||
IEnumerable<FileSystemPath> GetEntities(FileSystemPath path);
|
||||
IEnumerable<FileSystemPath> GetEntityPaths(FileSystemPath path);
|
||||
IEnumerable<FileSystemPath> GetDirectoryPaths(FileSystemPath path);
|
||||
IEnumerable<FileSystemPath> GetFilePaths(FileSystemPath path);
|
||||
|
||||
bool Exists(FileSystemPath path);
|
||||
Stream CreateFile(FileSystemPath path);
|
||||
Stream OpenFile(FileSystemPath path, FileAccess access);
|
||||
@@ -41,4 +45,24 @@ public void WriteAllText(FileSystemPath path, string content)
|
||||
public static class IFileSystemExtensions
|
||||
{
|
||||
public static ReadOnlyFileSystem AsReadOnlyFileSystem(this IFileSystem self) => new(self);
|
||||
|
||||
public static RelativeFileSystem AsRelativeFileSystem(this IFileSystem self, PathTransformation toAbsolutePath, PathTransformation toRelativePath)
|
||||
{
|
||||
return new(self, toAbsolutePath, toRelativePath);
|
||||
}
|
||||
|
||||
public static IEnumerable<IFileSystemEntity> GetEntities(this IFileSystem self, FileSystemPath path)
|
||||
{
|
||||
return self.GetEntityPaths(path).Select(p => IFileSystemEntity.Create(self, p));
|
||||
}
|
||||
|
||||
public static IEnumerable<VirtualDirectory> GetDirectories(this IFileSystem self, FileSystemPath path)
|
||||
{
|
||||
return self.GetDirectoryPaths(path).Select(p => VirtualDirectory.Create(self, p));
|
||||
}
|
||||
|
||||
public static IEnumerable<VirtualFile> GetFiles(this IFileSystem self, FileSystemPath path)
|
||||
{
|
||||
return self.GetFilePaths(path).Select(p => VirtualFile.Create(self, p));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user