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 #76109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
}
}


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
29 changes: 0 additions & 29 deletions src/doc/unstable-book/src/language-features/const-fn.md

This file was deleted.