Skip to main content

Module fs

Module fs 

Source
Expand description

Where the in-app picker reads: the system’s file system (StdFs, the default), or a folder held in memory (MemoryFs), for the web build, which has no file system, and for tests.

The picker and the preview providers read through a SharedFs: listing a folder, the facts of a path, the first bytes of a file. The picker’s New folder is the one thing it writes: StdFs makes the folder, and a MemoryFs refuses (it is read-only; the picker says so).

use std::path::Path;
use egui_pop_api::files::fs::{FileSystem, MemoryFs};

let fs = MemoryFs::new()
    .file("/demo/notes.txt", b"Hello".to_vec())
    .dir("/demo/Photos");
let names: Vec<String> = fs.read_dir(Path::new("/demo")).unwrap().into_iter().map(|e| e.name).collect();
assert_eq!(names, ["Photos", "notes.txt"]);
assert_eq!(fs.metadata(Path::new("/demo/notes.txt")).unwrap().len, 5);
assert_eq!(fs.read(Path::new("/demo/notes.txt"), 2).unwrap(), b"He");

Structs§

DirItem
One entry of a folder, as a file system lists it.
MemoryFs
A folder tree held in memory: files with their bytes and their modification time, and folders (a file’s folders exist with it).
Meta
The facts of a path.
StdFs
The system’s file system, through std::fs.

Traits§

FileSystem
What the picker and the preview providers read from.

Functions§

native
The system’s file system.

Type Aliases§

SharedFs
A file system shared by the picker, its preview and the workers.