Skip to content

Commit

Permalink
initial implementation of OpenOptions to c_int
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoPonzi committed Aug 30, 2020
1 parent fe8ab8a commit 27c90b8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/std/src/sys/unix/fs.rs
Expand Up @@ -692,6 +692,7 @@ impl OpenOptions {
}
}


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> {
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

0 comments on commit 27c90b8

Please sign in to comment.