From 27c90b881df93b53fd3f24dcbfed116379c2fc69 Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Sun, 30 Aug 2020 16:21:41 +0200 Subject: [PATCH] initial implementation of OpenOptions to c_int --- library/std/src/sys/unix/fs.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index acb18e6d064..59dfd9f9dc4 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -692,6 +692,7 @@ impl OpenOptions { } } + impl File { pub fn open(path: &Path, opts: &OpenOptions) -> io::Result { let path = cstr(path)?; @@ -962,6 +963,12 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> { Ok(()) } +pub fn get_openopetions_as_cint(from: OpenOptions) -> io::Result { + 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) })?;