OPFS Project
A Rust library for working with the Origin Private File System (OPFS) in WebAssembly applications.
Features
- File and directory operations in OPFS
- Support for fuse.link files to create symbolic links between directories
- Package management functionality for handling npm-style dependencies
- Asynchronous API for all file operations
Use Cases
- Web applications that need persistent local storage
- Package managers for web-based development environments
- Applications that need to manage complex file structures in the browser
- Tools that require fast access to local files without user interaction
Development Setup
- Install Rust and Cargo
- Install wasm-pack:
cargo install wasm-pack
- Build the project:
wasm-pack build
- Run tests:
wasm-pack test --firefox --headless
API
File Operations
opfs::read_dir(path)
- Read directory contentsopfs::read(path)
- Read file contentsopfs::write(path, content)
- Write content to fileopfs::create_dir_all(path)
- Create directory and all parent directoriesopfs::remove(path)
- Remove a fileopfs::exists(path)
- Check if file or directory exists
Package Management
package_manager::install_deps(package_lock)
- Install dependencies from package-lock.json
Fuse Link Operations
fuse::fuse_link(src, dst)
- Create fuse link between source and destination directoriesfuse::read(path)
- Read file content with fuse.link supportfuse::read_dir(path)
- Read directory contents with fuse.link support
Testing
Tests are written using wasm-bindgen-test and can be run with:
Note: Tests require a modern browser with OPFS support (Firefox 116+, Chrome 114+).
License
MIT