Adobe AIR like filesystem

I implemented a file system abstraction which for now consists mostly of a File object, an immutable path pointing to either a file or directory, regardless of whether it exists or nothing. It features:

  • Synchronous and asynchronous operations (uses tokio::fs under the hood)
  • Path resolution and normalization
  • Obtain relative path (like File::new("C:/qux/bar").relative_path(&File::new("C:/qux")) == "..".to_owned()

Path resolution, normalization and relativity are ported from NodeJS to Rust (so the implementation looks verbose!).

The following are available in Rialight projects (this framework isn't yet available), as it sets internal global variables called APPLICATION_DIRECTORY and APPLICATION_STORAGE_DIRECTORY:

  • Application installation directory (app: URL)
  • Application storage directory (app-storage: URL)

Things lacking compared to Adobe AIR:

  • No "Browse file" or "Save As" dialogs yet

Things trivial to add:

  • Contents streaming

Note that I don't think it works at the browser (not sure what happens), but futurely I can emulate app: and app-storage: File operations with IndexedDB in the browser. I'm also interested in knowing how to make use of file handles (file references obtained via "Browse files" dialog).

Links: