initial implementation of OpenOptions to c_int
This commit is contained in:
parent
fe8ab8a530
commit
27c90b881d
1 changed files with 7 additions and 0 deletions
|
@ -692,6 +692,7 @@ impl OpenOptions {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl File {
|
||||
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
|
||||
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<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) })?;
|
||||
|
|
Loading…
Add table
Reference in a new issue