Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to convert OpenOptions to c_int #76110

Merged
merged 8 commits into from
Sep 22, 2020
7 changes: 7 additions & 0 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ impl OpenOptions {
}
}


FedericoPonzi marked this conversation as resolved.
Show resolved Hide resolved
impl File {
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
let path = cstr(path)?;
Expand Down Expand Up @@ -962,6 +963,12 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
Ok(())
}

pub fn get_openopetions_as_cint(from: OpenOptions) -> io::Result<libc::c_int> {
FedericoPonzi marked this conversation as resolved.
Show resolved Hide resolved
let access_mode = from.get_access_mode()?;
let creation_mode = from.get_creation_mode()?;
Ok(creation_mode | access_mode)
}

pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
let p = cstr(p)?;
cvt_r(|| unsafe { libc::chmod(p.as_ptr(), perm.mode) })?;
Expand Down