diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 5d42012dcce..01edaeabe05 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -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)) } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 1df34e5f393..6c5e4181ab5 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -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; diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 77634ab77ca..ce83ab596e2 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -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) -> libc::intptr_t; fn unsupervise(); fn shape_log_str(t: *sys::type_desc, data: T) -> str; @@ -45,11 +40,6 @@ fn get_type_desc() -> *type_desc { rusti::get_tydesc::() 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() -> uint unsafe { rusti::size_of::() @@ -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::() == 1u;