mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-15 10:07:30 +00:00
rt/core: impl os::getcwd() in rust ref #4812
This commit is contained in:
parent
878a31066d
commit
4bc26ce575
@ -68,10 +68,17 @@ pub mod rustrt {
|
||||
}
|
||||
|
||||
pub const TMPBUF_SZ : uint = 1000u;
|
||||
const BUF_BYTES : uint = 2048u;
|
||||
|
||||
pub fn getcwd() -> Path {
|
||||
let buf = [0 as libc::c_char, ..BUF_BYTES];
|
||||
unsafe {
|
||||
Path(rustrt::rust_getcwd())
|
||||
if(0 as *libc::c_char == libc::getcwd(
|
||||
&buf[0],
|
||||
BUF_BYTES as libc::size_t)) {
|
||||
fail!();
|
||||
}
|
||||
Path(str::raw::from_c_str(&buf[0]))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,25 +52,6 @@ timegm(struct tm *tm)
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" CDECL rust_str *
|
||||
rust_getcwd() {
|
||||
rust_task *task = rust_get_current_task();
|
||||
LOG(task, task, "rust_getcwd()");
|
||||
|
||||
char cbuf[BUF_BYTES];
|
||||
|
||||
#if defined(__WIN32__)
|
||||
if (!_getcwd(cbuf, sizeof(cbuf))) {
|
||||
#else
|
||||
if (!getcwd(cbuf, sizeof(cbuf))) {
|
||||
#endif
|
||||
task->fail();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return make_str(task->kernel, cbuf, strlen(cbuf), "rust_str(getcwd)");
|
||||
}
|
||||
|
||||
#if defined(__WIN32__)
|
||||
extern "C" CDECL rust_vec_box *
|
||||
rust_env_pairs() {
|
||||
|
@ -29,7 +29,6 @@ rust_new_task_in_sched
|
||||
rust_num_threads
|
||||
rust_path_is_dir
|
||||
rust_path_exists
|
||||
rust_getcwd
|
||||
rust_get_stdin
|
||||
rust_get_stdout
|
||||
rust_get_stderr
|
||||
@ -43,7 +42,6 @@ rust_sched_current_nonlazy_threads
|
||||
rust_sched_threads
|
||||
rust_set_exit_status
|
||||
rust_start
|
||||
rust_getcwd
|
||||
rust_env_pairs
|
||||
rust_task_yield
|
||||
rust_task_is_unwinding
|
||||
|
Loading…
Reference in New Issue
Block a user