Rustify Sys::open and some fs:: error handling.
This commit is contained in:
@@ -10,6 +10,7 @@ use rand_xorshift::XorShiftRng;
|
||||
|
||||
use crate::{
|
||||
c_str::CStr,
|
||||
error::ResultExt,
|
||||
fs::File,
|
||||
header::{
|
||||
ctype,
|
||||
@@ -673,12 +674,14 @@ pub unsafe extern "C" fn mkostemps(
|
||||
suffix_len: c_int,
|
||||
mut flags: c_int,
|
||||
) -> c_int {
|
||||
// TODO: Rustify impl
|
||||
|
||||
flags &= !O_ACCMODE;
|
||||
flags |= O_RDWR | O_CREAT | O_EXCL;
|
||||
|
||||
inner_mktemp(name, suffix_len, || {
|
||||
let name = CStr::from_ptr(name);
|
||||
let fd = Sys::open(name, flags, 0o600);
|
||||
let fd = Sys::open(name, flags, 0o600).or_minus_one_errno();
|
||||
|
||||
if fd >= 0 {
|
||||
Some(fd)
|
||||
|
||||
Reference in New Issue
Block a user