cap_primitives/fs/
open_ambient.rs

1//! This defines `open_ambient`, for unsandboxed file opening.
2
3use crate::fs::{open_ambient_impl, OpenOptions};
4use crate::AmbientAuthority;
5use std::path::Path;
6use std::{fs, io};
7
8/// Open a file named by a bare path, using the host process' ambient
9/// authority.
10///
11/// # Ambient Authority
12///
13/// This function is not sandboxed and may trivially access any path that the
14/// host process has access to.
15#[inline]
16pub fn open_ambient(
17    path: &Path,
18    options: &OpenOptions,
19    ambient_authority: AmbientAuthority,
20) -> io::Result<fs::File> {
21    Ok(open_ambient_impl(path, options, ambient_authority)?)
22}