core: Move last_os_error from sys to os

This commit is contained in:
Brian Anderson 2012-04-19 01:23:00 -07:00
parent 01e20dd0b3
commit 1cad6322c3
3 changed files with 13 additions and 18 deletions

View File

@ -317,7 +317,7 @@ impl of writer for *libc::FILE {
let nout = libc::fwrite(vbuf as *c_void, len, 1u, self);
if nout < 1 as size_t {
#error("error writing buffer");
log(error, sys::last_os_error());
log(error, os::last_os_error());
fail;
}
}
@ -348,7 +348,7 @@ impl of writer for fd_t {
let nout = libc::write(self, vb, len);
if nout < 0 as ssize_t {
#error("error writing buffer");
log(error, sys::last_os_error());
log(error, os::last_os_error());
fail;
}
count += nout as uint;
@ -402,7 +402,7 @@ fn mk_file_writer(path: str, flags: [fileflag])
(S_IRUSR | S_IWUSR) as c_int)
};
if fd < (0 as c_int) {
result::err(#fmt("error opening %s: %s", path, sys::last_os_error()))
result::err(#fmt("error opening %s: %s", path, os::last_os_error()))
} else {
result::ok(fd_writer(fd, true))
}

View File

@ -32,6 +32,7 @@ export exe_suffix, dll_suffix, sysname;
export homedir, list_dir, list_dir_path, path_is_dir, path_exists,
make_absolute, make_dir, remove_dir, change_dir, remove_file,
copy_file;
export last_os_error;
// FIXME: move these to str perhaps?
export as_c_charp, fill_charp_buf;
@ -43,6 +44,7 @@ native mod rustrt {
fn rust_path_exists(path: *libc::c_char) -> c_int;
fn rust_list_files(path: str) -> [str];
fn rust_process_wait(handle: c_int) -> c_int;
fn last_os_error() -> str;
}
@ -623,6 +625,10 @@ fn remove_file(p: path) -> bool {
}
}
#[doc = "Get a string representing the platform-dependent last error"]
fn last_os_error() -> str {
rustrt::last_os_error()
}
#[cfg(target_os = "macos")]
@ -659,6 +665,10 @@ mod consts {
#[cfg(test)]
mod tests {
#[test]
fn last_os_error() {
log(debug, last_os_error());
}
fn make_rand_name() -> str {
import rand;

View File

@ -2,7 +2,6 @@
export type_desc;
export get_type_desc;
export last_os_error;
export size_of;
export align_of;
export refcount;
@ -18,10 +17,6 @@ enum type_desc = {
#[abi = "cdecl"]
native mod rustrt {
// Explicitly re-export native stuff we want to be made
// available outside this crate. Otherwise it's
// visible-in-crate, but not re-exported.
fn last_os_error() -> str;
fn refcount<T>(t: @T) -> libc::intptr_t;
fn unsupervise();
fn shape_log_str<T>(t: *sys::type_desc, data: T) -> str;
@ -45,11 +40,6 @@ fn get_type_desc<T>() -> *type_desc {
rusti::get_tydesc::<T>() as *type_desc
}
#[doc = "Get a string representing the platform-dependent last error"]
fn last_os_error() -> str {
rustrt::last_os_error()
}
#[doc = "Returns the size of a type"]
fn size_of<T>() -> uint unsafe {
rusti::size_of::<T>()
@ -84,11 +74,6 @@ fn set_exit_status(code: int) {
#[cfg(test)]
mod tests {
#[test]
fn last_os_error() {
log(debug, last_os_error());
}
#[test]
fn size_of_basic() {
assert size_of::<u8>() == 1u;