Skip to content
Snippets Groups Projects
Commit 0e489379 authored by jD91mZM2's avatar jD91mZM2
Browse files

Merge branch 'tmpfile' into 'master'

Implement tmpfile

See merge request redox-os/relibc!154
parents 8021ade2 42811717
No related branches found
No related tags found
No related merge requests found
......@@ -855,9 +855,28 @@ pub extern "C" fn tempnam(_dir: *const c_char, _pfx: *const c_char) -> *mut c_ch
unimplemented!();
}
// #[no_mangle]
#[no_mangle]
pub extern "C" fn tmpfile() -> *mut FILE {
unimplemented!();
extern "C" {
fn mkstemp(name: *mut c_char) -> c_int;
}
let mut file_name = *b"/tmp/tmpfileXXXXXX";
let file_name = file_name.as_mut_ptr() as *mut c_char;
let fd = unsafe { mkstemp(file_name) };
if fd < 0 {
return ptr::null_mut();
}
let fp = fdopen(fd, b"w+".as_ptr() as *const i8);
platform::unlink(file_name);
if fp == ptr::null_mut() {
platform::close(fd);
}
fp
}
// #[no_mangle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment