Skip to content

Commit 1cad632

Browse files
committed
core: Move last_os_error from sys to os
1 parent 01e20dd commit 1cad632

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/libcore/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl of writer for *libc::FILE {
317317
let nout = libc::fwrite(vbuf as *c_void, len, 1u, self);
318318
if nout < 1 as size_t {
319319
#error("error writing buffer");
320-
log(error, sys::last_os_error());
320+
log(error, os::last_os_error());
321321
fail;
322322
}
323323
}
@@ -348,7 +348,7 @@ impl of writer for fd_t {
348348
let nout = libc::write(self, vb, len);
349349
if nout < 0 as ssize_t {
350350
#error("error writing buffer");
351-
log(error, sys::last_os_error());
351+
log(error, os::last_os_error());
352352
fail;
353353
}
354354
count += nout as uint;
@@ -402,7 +402,7 @@ fn mk_file_writer(path: str, flags: [fileflag])
402402
(S_IRUSR | S_IWUSR) as c_int)
403403
};
404404
if fd < (0 as c_int) {
405-
result::err(#fmt("error opening %s: %s", path, sys::last_os_error()))
405+
result::err(#fmt("error opening %s: %s", path, os::last_os_error()))
406406
} else {
407407
result::ok(fd_writer(fd, true))
408408
}

src/libcore/os.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export exe_suffix, dll_suffix, sysname;
3232
export homedir, list_dir, list_dir_path, path_is_dir, path_exists,
3333
make_absolute, make_dir, remove_dir, change_dir, remove_file,
3434
copy_file;
35+
export last_os_error;
3536

3637
// FIXME: move these to str perhaps?
3738
export as_c_charp, fill_charp_buf;
@@ -43,6 +44,7 @@ native mod rustrt {
4344
fn rust_path_exists(path: *libc::c_char) -> c_int;
4445
fn rust_list_files(path: str) -> [str];
4546
fn rust_process_wait(handle: c_int) -> c_int;
47+
fn last_os_error() -> str;
4648
}
4749

4850

@@ -623,6 +625,10 @@ fn remove_file(p: path) -> bool {
623625
}
624626
}
625627

628+
#[doc = "Get a string representing the platform-dependent last error"]
629+
fn last_os_error() -> str {
630+
rustrt::last_os_error()
631+
}
626632

627633

628634
#[cfg(target_os = "macos")]
@@ -659,6 +665,10 @@ mod consts {
659665
#[cfg(test)]
660666
mod tests {
661667

668+
#[test]
669+
fn last_os_error() {
670+
log(debug, last_os_error());
671+
}
662672

663673
fn make_rand_name() -> str {
664674
import rand;

src/libcore/sys.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
export type_desc;
44
export get_type_desc;
5-
export last_os_error;
65
export size_of;
76
export align_of;
87
export refcount;
@@ -18,10 +17,6 @@ enum type_desc = {
1817

1918
#[abi = "cdecl"]
2019
native mod rustrt {
21-
// Explicitly re-export native stuff we want to be made
22-
// available outside this crate. Otherwise it's
23-
// visible-in-crate, but not re-exported.
24-
fn last_os_error() -> str;
2520
fn refcount<T>(t: @T) -> libc::intptr_t;
2621
fn unsupervise();
2722
fn shape_log_str<T>(t: *sys::type_desc, data: T) -> str;
@@ -45,11 +40,6 @@ fn get_type_desc<T>() -> *type_desc {
4540
rusti::get_tydesc::<T>() as *type_desc
4641
}
4742

48-
#[doc = "Get a string representing the platform-dependent last error"]
49-
fn last_os_error() -> str {
50-
rustrt::last_os_error()
51-
}
52-
5343
#[doc = "Returns the size of a type"]
5444
fn size_of<T>() -> uint unsafe {
5545
rusti::size_of::<T>()
@@ -84,11 +74,6 @@ fn set_exit_status(code: int) {
8474
#[cfg(test)]
8575
mod tests {
8676

87-
#[test]
88-
fn last_os_error() {
89-
log(debug, last_os_error());
90-
}
91-
9277
#[test]
9378
fn size_of_basic() {
9479
assert size_of::<u8>() == 1u;

0 commit comments

Comments
 (0)