Crates.io | vfstool_lib |
lib.rs | vfstool_lib |
version | 0.2.0 |
created_at | 2025-04-25 05:54:19.107148+00 |
updated_at | 2025-07-07 15:24:25.923008+00 |
description | A library for constructing and manipulating virtual file systems in Rust, based on OpenMW's VFS implementation. |
homepage | https://github.com/magicaldave/vfstool |
repository | https://github.com/magicaldave/vfstool |
max_upload_size | |
id | 1648542 |
size | 79,137 |
dw_vfs_lib is a reimplementation of OpenMW's virtual file system, or VFS. It provides tools for working with directory structures, archive files, and file metadata, making it ideal for applications that need to handle complex file hierarchies - including complex mod loadouts handled by mod managers. dw_vfs_lib does not inherently depend on OpenMW or any particular game or technology - it can be repurposed easily for almost any use case.
Virtual File System (VFS):
Parallel Processing:
rayon
crate for efficient parallel operations on large file sets.Serialization (Optional):
serde
.Archive Support:
ba2
crate to handle Bethesda archive formats (e.g., BSA, BA2).Add dw_vfs_lib to your Cargo.toml:
[dependencies]
dw_vfs_lib = "0.1.0"
To enable optional serialization features:
[dependencies]
dw_vfs_lib = { version = "0.1.0", features = ["serde"] }
use dw_vfs_lib::VFS;
use std::path::PathBuf;
fn main() {
// Directories to scan
let search_dirs = vec![
PathBuf::from("path/to/dir1"),
PathBuf::from("path/to/dir2"),
PathBuf::from("path/to/dir3"),
];
// List of Bethesda archive files to load
let archive_list = Some(vec!["archive1.bsa", "archive2.bsa"]);
// Construct the VFS
let vfs = VFS::from_directories(search_dirs, archive_list);
// Example: Iterate over all files in the VFS
for (path, file) in vfs.iter() {
println!("File: {:?}, Path: {:?}", file, path);
}
}
Enable the serialize
feature to serialize the VFS structure to your preferred text format:
use dw_vfs_lib::{VFS, SerializeType};
fn main() {
let search_dirs = vec![
PathBuf::from("path/to/dir1"),
PathBuf::from("path/to/dir2"),
PathBuf::from("path/to/dir3"),
];
let vfs = VFS::from_directories(search_dirs, None);
// Serialize the VFS to JSON
let tree = vfs.tree(false);
let json = vfs.serialize_from_tree(&tree, SerializeType::Json).unwrap();
println!("Serialized VFS: {}", json);
}
default
: No optional features enabled.serialize
: Enables serialization to JSON, YAML, and TOML.This project is licensed under the MIT License. See the LICENSE file for details.