Skip to content

Add in-memory virtual filesystem support to shim_filesystem - #760

Merged
NSoiffer merged 2 commits into
daisy:mainfrom
dtsengchromium:in-memory-virtual-filesystem
Sep 19, 2026
Merged

NSoiffer merged 2 commits into
daisy:mainfrom
dtsengchromium:in-memory-virtual-filesystem

Conversation

@dtsengchromium

Copy link
Copy Markdown
Contributor

Overview

This PR adds support for registering and reading in-memory virtual files in shim_filesystem via shim_filesystem::add_in_memory_file(path, content).

Context & Motivation

When embedding MathCAT in environments where extracting rules and YAML assets to physical disk is impractical or prohibited (e.g. mobile platforms like Android or environments with read-only sandbox filesystems), rules files and language YAMLs can be loaded directly from memory / packaged application bundles into MathCAT without touching the disk.

Summary of Changes

  • Added thread-safe in-memory file and directory tracking (IN_MEMORY_FILES, IN_MEMORY_DIRS) in shim_filesystem.
  • Added public shim_filesystem::add_in_memory_file(path: &str, content: &str) to register virtual file paths and their parent directory hierarchy.
  • Updated is_file_shim, is_dir_shim, find_files_in_dir_that_ends_with_shim, and read_to_string_shim to check in-memory stores before falling back to physical disk.
  • Updated PreferenceManager::initialize in src/prefs.rs to use canonicalize_shim so virtual rules paths are normalized without requiring physical directory existence on the host filesystem.
  • Added unit test in src/shim_filesystem.rs validating in-memory file registration, path inspection, and reading.

@NSoiffer

Copy link
Copy Markdown
Collaborator

@dtsengchromium: can you update your rust env and then fix the clippy warnings. It seems that clippy keeps improving and finding more things to flag. I'm on holiday at the moment otherwise I would just fix this.

@dtsengchromium

Copy link
Copy Markdown
Contributor Author

Thanks @NSoiffer! I updated to the latest Rust toolchain and fixed all Clippy warnings across the codebase and test suites (including --all-targets and --features no-unsafe), and confirmed that all 5,100+ tests pass cleanly locally.

I've pushed the updates to the branch. Whenever you have a chance, please approve the workflow run. Enjoy your holiday!

@moritz-gross moritz-gross added the rust Coding in Rust label Sep 16, 2026
@NSoiffer
NSoiffer merged commit a6e65c8 into daisy:main Sep 19, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Triage to Done in MathCAT Project Board Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Coding in Rust

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants