Skip to content

Commit

Permalink
rt/core: impl os::getcwd() in rust ref #4812
Browse files Browse the repository at this point in the history
  • Loading branch information
olsonjeffery authored and brson committed Mar 11, 2013
1 parent 878a310 commit 4bc26ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
9 changes: 8 additions & 1 deletion src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
}
}

Expand Down
19 changes: 0 additions & 19 deletions src/rt/rust_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions src/rt/rustrt.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4bc26ce

Please sign in to comment.