pkNX/pkNX.Containers/VFS/Util/IFileSystemEntity.cs
2023-01-18 18:03:51 +01:00

32 lines
720 B
C#

namespace pkNX.Containers.VFS;
public interface IFileSystemEntity
{
IFileSystem FileSystem { get; }
FileSystemPath Path { get; }
string Name { get; }
VirtualDirectory ParentDirectory { get; }
internal static IFileSystemEntity Create(IFileSystem fileSystem, FileSystemPath path)
{
if (path.IsFile)
return VirtualFile.Create(fileSystem, path);
return VirtualDirectory.Create(fileSystem, path);
}
}
public static class IFileSystemEntityExtensions
{
public static void Delete(this IFileSystemEntity e)
{
e.FileSystem.Delete(e.Path);
}
public static void Exists(this IFileSystemEntity e)
{
e.FileSystem.Exists(e.Path);
}
}