Skip to main content

Crate optic_file

Crate optic_file 

Source
Expand description

Sanitary file I/O and cached-path resolution for the Optic engine.

All fallible functions return OpticResult wrapping OpticErrorKind::File errors with descriptive messages.

§Cache path convention

Assets are cached alongside the source file in an optc/ subdirectory:

assets/tex/foo.png     → assets/tex/optc/foo.otxtr
models/cube.obj        → models/optc/cube.omesh
shaders/main.glsl      → shaders/optc/main.oshdr

Functions§

cached_path
Compute the cache path for a source asset.
create_dir
Create a directory and all parent directories (like mkdir -p).
exists
Check whether a file or directory exists at the given path.
extension
Extract the file extension from a path.
name
Extract the file stem (name without extension) from a path.
read_bytes
Read a file as raw bytes.
read_string
Read a file as a UTF-8 string.
write_bytes
Write raw bytes to a file, creating parent directories if needed.
write_string
Write a UTF-8 string to a file, creating parent directories if needed.