Avfs.Abstractions
0.1.0
dotnet add package Avfs.Abstractions --version 0.1.0
NuGet\Install-Package Avfs.Abstractions -Version 0.1.0
<PackageReference Include="Avfs.Abstractions" Version="0.1.0" />
paket add Avfs.Abstractions --version 0.1.0
#r "nuget: Avfs.Abstractions, 0.1.0"
// Install Avfs.Abstractions as a Cake Addin #addin nuget:?package=Avfs.Abstractions&version=0.1.0 // Install Avfs.Abstractions as a Cake Tool #tool nuget:?package=Avfs.Abstractions&version=0.1.0
A·VFS
A Virtual File System for .NET (6+)
- Straightforward
IFileSystem
interface, making extension easy - The
VfsPath
struct represents paths in the VFS and simplifies path manipulation - Basic implementations of
IFileSystem
PhysicalFileSystem
represents a physical folderMountFileSystem
combines multiple file systems together using mount pointsReadOnlyFileSystemDecorator
wraps around another file system, allowing only read operations
- Some basic implementations of
IFileSystem
(physical path, read-only decorator, and mount file system) - Separate package
Avfs.Abstractions
for the abstractions
Example
// Setup A VFS
var fileSystem = new MountFileSystem();
var userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var savesFolderPath = Path.Combine(userProfilePath, "MyGameSaves");
fileSystem.Mount(VfsPath.Parse("/saves/"), new PhysicalFileSystem(savesFolderPath));
var gameDataFolderPath = Path.GetFullPath("Content");
fileSystem.Mount(VfsPath.Parse("/data/"), new PhysicalFileSystem(gameDataFolderPath));
// Create directory
if (!fileSystem.Exists(VfsPath.Parse("/data/config/")))
fileSystem.Create(VfsPath.Parse("/data/config/"));
// Create a file
fileSystem.Open(VfsPath.Parse("/saves/1.save"), FileMode.Create, FileAccess.Write, FileShare.Write);
// Enumerate over a directory
fileSystem.Enumerate(VfsPath.Parse("/saves/"), "*.save", SearchOption.TopDirectoryOnly, SearchTargets.File);
// Delete a file/directory
fileSystem.Delete(VfsPath.Parse("/saves/1.save"));
Is it for you?
A·VFS is meant for applications/games to collect all their assets, settings, user data, etc. in a VFS, hiding the complexities of different storage locations or differing assets for configuration (e.g. debug vs production).
A·VFS is not meant to replace any and all kinds of IO of your application to improve testability. For such scenarios take a look at other more complex VFS libraries out there.
Installation
Install via Nuget. No other dependencies apart from the abstractions package 😃
Usage
Create your desired IFileSystem
(s) and use them. Nothing more to it.
There are some good-to-know (tm) facts about VfsPath
as it is designed to be more restrictive than normal paths:
- Directory separator is always a forward slash (
/
), regardless of platform - Paths are always absolute and thus start with a directory separator (e.g.
/saves/1
) - Paths to directories always end with a directory separator (e.g.
/saves/
) - Path to files do not end with a directory separator (e.g.
/saves/1
) - Any part of a path (stuff between/after directory separators) must follow these rules:
- Only consist of Unicode letters, Unicode digits, underscore (
_
), hyphen (-
), or dot (.
) - The last character must be a Unicode letter or Unicode digit
- Dot characters must not follow each other (->
..
is not allowed)
- Only consist of Unicode letters, Unicode digits, underscore (
Build
Run build.cmd
orbuild.sh
. Will use Compile
target by default. Other targets include: Clean
, Test
, Pack
, FullBuild
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Avfs.Abstractions:
Package | Downloads |
---|---|
Avfs
A Virtual File System for .NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.0 | 221 | 8/3/2023 |