vFrame VFS
May 5, 2026 · View on GitHub
vFrame VFS
A virtual file system for Unity and .NET projects that unifies directory-based storage and .vpk package-based storage behind one API.
Features
- Exposes unified
IFileSystemManagerandIVirtualFileSystemabstractions - Uses
FileSystemManager.AddFileSystem(VFSPath)to auto-detect directories and.vpkpackages - Supports synchronous reads with
GetStream(),ReadAllText(), andReadAllBytes() - Supports asynchronous reads with
GetStreamAsync(),ReadAllTextAsync(), andReadAllBytesAsync() - Includes
PackageVirtualFileSystemfor creating, writing, and reading.vpkfiles - Includes
PackageVirtualFileOperator.CreatePackage()andExtractPackage()for batch workflows - Includes
VFSPathfor normalization, combination, and relative-path handling - Ships a Unity extension for Android
StreamingAssetsaccess - Splits runtime code into
vFrame.VFSandvFrame.VFS.UnityExtensionassemblies
Requirements
- Unity
2019.4.40f1or a compatible2019.4+release vFrame.CoredependencyvFrame.Core.Unitydependency for the Unity extension package
Installation
This repository contains two UPM packages:
com.vyronlee.vframe.vfs1.0.1com.vyronlee.vframe.vfs.unity-extension1.0.1
Add the dependencies to your project's Packages/manifest.json:
{
"dependencies": {
"com.vyronlee.vframe.core": "https://github.com/VyronLee/vFrame.Core.git#upm-core",
"com.vyronlee.vframe.vfs": "https://github.com/VyronLee/vFrame.VFS.git#upm-vfs",
"com.vyronlee.vframe.vfs.unity-extension": "https://github.com/VyronLee/vFrame.VFS.git#upm-vfs-unity"
}
}
You can also install them through Unity Package Manager with Window > Package Manager > Add package from git URL....
Quick Start
Mount a directory and read text
using vFrame.VFS;
var manager = new FileSystemManager();
manager.Create();
var root = VFSPath.Create(UnityEngine.Application.persistentDataPath).AsDirectory();
manager.AddFileSystem(root);
var text = manager.ReadAllText("config/game.json");
manager.Destroy();
Mount a .vpk package and read content
using vFrame.VFS;
var manager = new FileSystemManager();
manager.Create();
manager.AddFileSystem(VFSPath.Create(UnityEngine.Application.streamingAssetsPath + "/data.vpk"));
using (var stream = manager.GetStream("config/game.json")) {
var json = stream.ReadAllText();
}
manager.Destroy();
Usage
Scenario 1: Work with multiple file systems
FileSystemManager checks mounted file systems in insertion order. The first match wins.
using vFrame.VFS;
var manager = new FileSystemManager();
manager.Create();
manager.AddFileSystem(VFSPath.Create(UnityEngine.Application.persistentDataPath).AsDirectory());
manager.AddFileSystem(VFSPath.Create(UnityEngine.Application.streamingAssetsPath + "/base.vpk"));
var bytes = manager.ReadAllBytes("bundles/ui/panel.prefab");
manager.Destroy();
Scenario 2: Build paths with VFSPath
using vFrame.VFS;
var root = VFSPath.Create("D:/GameData").AsDirectory();
var file = VFSPath.Create("config/settings.json");
var full = root.Combine(file);
var fileName = file.GetFileName();
var extension = file.GetExtension();
var directory = full.GetDirectory();
var relative = full.GetRelative(root);
Scenario 3: Create a .vpk package
using System.IO;
using vFrame.VFS;
var package = PackageVirtualFileSystem.CreatePackage("D:/Build/data.vpk");
using (var input = File.OpenRead("D:/Build/config/game.json")) {
package.AddStream(
"config/game.json",
input,
BlockFlags.BlockEncryptXor,
PackageFileSystemConst.Id,
BlockFlags.BlockCompressLZMA);
}
package.Flush(true);
package.Close();
Scenario 4: Pack and extract a directory
using vFrame.VFS;
PackageVirtualFileOperator.CreatePackage(
"D:/Build/RawData",
"D:/Build/content.vpk",
force: true);
PackageVirtualFileOperator.ExtractPackage(
"D:/Build/content.vpk",
"D:/Build/Extracted",
force: true);
Scenario 5: Read files asynchronously
using vFrame.VFS;
var manager = new FileSystemManager();
manager.Create();
manager.AddFileSystem(VFSPath.Create("D:/GameData").AsDirectory());
var request = manager.ReadAllTextAsync("config/game.json");
while (!request.IsDone) {
}
var text = request.Result;
manager.Destroy();
Architecture Overview
Directory layout
Assets/vFrame.VFS/Runtime/ConstantsAssets/vFrame.VFS/Runtime/ExceptionsAssets/vFrame.VFS/Runtime/PackageAssets/vFrame.VFS/Runtime/PoolsAssets/vFrame.VFS/Runtime/StandardAssets/vFrame.VFS.UnityExtension/Runtime/3rdAssets/vFrame.VFS.UnityExtension/Runtime/StreamingAssets
Runtime modules
vFrame.VFS: core runtime withFileSystemManager,VFSPath,PackageVirtualFileSystem, andPackageVirtualFileOperatorvFrame.VFS.UnityExtension: Unity-specific runtime withvFrame.VFS.UnityExtension.FileSystemManager,SAStandardVirtualFileSystem, andSAPackageVirtualFileSystem
File system model
- Standard file system: handled by
StandardVirtualFileSystemfor directories - Package file system: handled by
PackageVirtualFileSystemfor.vpkfiles - Android
StreamingAssets: handled bySAStandardVirtualFileSystemandSAPackageVirtualFileSystem
Notes
PackageVirtualFileSystemreads existing package data in read-only mode and only supportsFileMode.OpenwithFileAccess.ReadFileSystemManager.ReadAllText()returns an empty string when no file is found, andReadAllBytes()returnsnullPackageVirtualFileOperator.CreatePackage()defaults toBlockFlags.BlockEncryptXor,PackageFileSystemConst.Id, andBlockFlags.BlockCompressLZMA- On Android, use
vFrame.VFS.UnityExtension.FileSystemManagerforStreamingAssets; do not usevFrame.VFS.FileSystemManager SAStandardVirtualFileSystem.GetFiles()currently throwsNotSupportedException, so AndroidStreamingAssetsenumeration is not supported
License
This project is licensed under the Apache License 2.0.