Skip to main content

safe_open

Function safe_open 

pub async fn safe_open(path: impl AsRef<Path>) -> Result<File, Error>
Expand description

Open path read-only with path-traversal protection.

Equivalent to OpenOptions::new().read(true).open(path). Rejects .. traversal, reserved device names and smuggled path prefixes (see sanitize_path). Absolute paths are permitted; use safe_open_in to confine the path to a trusted root directory instead.

Path rejection surfaces as io::ErrorKind::InvalidInput.