Expand description
Capability-gated filesystem operations.
Drop-in replacements for std::fs functions that require a capability token
proving the caller has filesystem permission.
§Example
let root = test_root();
let cap = root.grant::<FsRead>();
let data = capsec_std::fs::read("/tmp/data.bin", &cap).unwrap();Functions§
- copy
- Copies a file. Requires both
FsReadandFsWritepermissions (passed as separate capability tokens). - create
- Creates or truncates a file for writing. Returns a
WriteFilethat implementsWrite+Seekbut NOTRead, enforcing the capability boundary beyond the function call. RequiresFsWritepermission. - create_
dir_ all - Creates all directories in the given path if they don’t exist.
Requires
FsWritepermission. - metadata
- Returns metadata about a file or directory.
Requires
FsReadpermission. - open
- Opens a file for reading. Returns a
ReadFilethat implementsRead+Seekbut NOTWrite, enforcing the capability boundary beyond the function call. RequiresFsReadpermission. - read
- Reads the entire contents of a file into a byte vector.
Requires
FsReadpermission. - read_
dir - Returns an iterator over the entries within a directory.
Requires
FsReadpermission. - read_
to_ string - Reads the entire contents of a file into a string.
Requires
FsReadpermission. - remove_
dir_ all - Recursively deletes a directory and all its contents.
Requires
FsWritepermission. - remove_
file - Deletes a file.
Requires
FsWritepermission. - rename
- Renames a file or directory.
Requires
FsWritepermission. - write
- Writes bytes to a file, creating it if it doesn’t exist, truncating if it does.
Requires
FsWritepermission.