Skip to main content

Virtual Filesystem (VFS)

The Virtual Filesystem provides a POSIX-like file and directory abstraction in browser memory. It enables applications to work with files and folders using familiar Unix-style paths and operations.

Architecture

Core Data Structures

VFS Interface

Initialization

Root Structure

VFS creates a Unix-like root structure on initialization:

Filesystem Flattening

The nested structure is flattened into a Map for O(1) lookups:
This provides O(1) path resolution instead of tree traversal:

Path Resolution

Unix-Style Path Handling

File Operations

Create File (touch)

Create Directory (mkdir)

Remove (rm)

Rename

Write File

Move

Copy

Trash Functionality

Move to Trash

Restore from Trash

Search Operations

Utility Operations

Get Size

Check Existence

Get Children

Event System

Change Notifications

Dynamic Content Sync

Large files are loaded asynchronously after initialization:
This keeps the initial bundle small by deferring large file loads.

Global Exposure

Future: IndexedDB Integration

The VFS is designed to integrate with IndexedDB for persistent storage:
This will enable:
  • User-created files persisting across sessions
  • Larger file support
  • Offline file access
  • Progressive sync on load

Performance Considerations

O(1) Lookups

Flattened map provides constant-time access:

Memory Usage

Typical VFS memory footprint:
  • ~1000 files/folders: ~500KB
  • ~10000 entries: ~5MB
  • Content stored as strings (UTF-16)

Batch Operations

Avoid individual operations in loops:

Best Practices

Ensure directory paths end with / for consistency:
Always normalize paths before operations:
Prevent errors by checking first:
Keep UI synchronized with filesystem:

Architecture

Overall system architecture and design

Storage

Future persistent VFS storage

Window Manager

Window management for file applications

Development

Build applications using VFS