Skip to content

Commit 27c90b8

Browse files
author
Federico Ponzi
committed
initial implementation of OpenOptions to c_int
1 parent fe8ab8a commit 27c90b8

File tree

1 file changed

+7
-0
lines changed
  • library/std/src/sys/unix

1 file changed

+7
-0
lines changed

library/std/src/sys/unix/fs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ impl OpenOptions {
692692
}
693693
}
694694

695+
695696
impl File {
696697
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
697698
let path = cstr(path)?;
@@ -962,6 +963,12 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
962963
Ok(())
963964
}
964965

966+
pub fn get_openopetions_as_cint(from: OpenOptions) -> io::Result<libc::c_int> {
967+
let access_mode = from.get_access_mode()?;
968+
let creation_mode = from.get_creation_mode()?;
969+
Ok(creation_mode | access_mode)
970+
}
971+
965972
pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
966973
let p = cstr(p)?;
967974
cvt_r(|| unsafe { libc::chmod(p.as_ptr(), perm.mode) })?;

0 commit comments

Comments
 (0)