Avfs 0.1.0

dotnet add package Avfs --version 0.1.0                
NuGet\Install-Package Avfs -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Avfs" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Avfs --version 0.1.0                
#r "nuget: Avfs, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Avfs as a Cake Addin
#addin nuget:?package=Avfs&version=0.1.0

// Install Avfs as a Cake Tool
#tool nuget:?package=Avfs&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 folder
    • MountFileSystem combines multiple file systems together using mount points
    • ReadOnlyFileSystemDecorator 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:

  1. Directory separator is always a forward slash (/), regardless of platform
  2. Paths are always absolute and thus start with a directory separator (e.g. /saves/1)
  3. Paths to directories always end with a directory separator (e.g. /saves/)
  4. Path to files do not end with a directory separator (e.g. /saves/1)
  5. Any part of a path (stuff between/after directory separators) must follow these rules:
    1. Only consist of Unicode letters, Unicode digits, underscore (_), hyphen (-), or dot (.)
    2. The last character must be a Unicode letter or Unicode digit
    3. Dot characters must not follow each other (-> .. is not allowed)

Build

Run build.cmd orbuild.sh. Will use Compile target by default. Other targets include: Clean, Test, Pack, FullBuild

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 191 8/3/2023