Skip to content

Commit 8f531e7

Browse files
committed
Convert rust_file_is_dir from estrs to cstrs. Issue #855
1 parent baa1e87 commit 8f531e7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/lib/fs.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os_fs;
44
import str;
55

66
native "rust" mod rustrt {
7-
fn rust_file_is_dir(path: str) -> int;
7+
fn rust_file_is_dir(path: istr::sbuf) -> int;
88
}
99

1010
fn path_sep() -> istr { ret istr::from_char(os_fs::path_sep); }
@@ -43,7 +43,9 @@ fn connect(pre: &path, post: &path) -> path {
4343
}
4444

4545
fn file_is_dir(p: &path) -> bool {
46-
ret rustrt::rust_file_is_dir(istr::to_estr(p)) != 0;
46+
ret istr::as_buf(p, { |buf|
47+
rustrt::rust_file_is_dir(buf) != 0
48+
});
4749
}
4850

4951
fn list_dir(p: &path) -> [istr] {

src/rt/rust_builtin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ rust_dirent_filename(rust_task *task, dirent* ent) {
444444
#endif
445445

446446
extern "C" CDECL int
447-
rust_file_is_dir(rust_task *task, rust_str *path) {
447+
rust_file_is_dir(rust_task *task, char *path) {
448448
struct stat buf;
449-
if (stat((char*)path->data, &buf)) {
449+
if (stat(path, &buf)) {
450450
return 0;
451451
}
452452
return S_ISDIR(buf.st_mode);

0 commit comments

Comments
 (0)