Convert rust_file_is_dir from estrs to cstrs. Issue #855
This commit is contained in:
parent
baa1e8790d
commit
8f531e769a
2 changed files with 6 additions and 4 deletions
|
@ -4,7 +4,7 @@ import os_fs;
|
||||||
import str;
|
import str;
|
||||||
|
|
||||||
native "rust" mod rustrt {
|
native "rust" mod rustrt {
|
||||||
fn rust_file_is_dir(path: str) -> int;
|
fn rust_file_is_dir(path: istr::sbuf) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_sep() -> istr { ret istr::from_char(os_fs::path_sep); }
|
fn path_sep() -> istr { ret istr::from_char(os_fs::path_sep); }
|
||||||
|
@ -43,7 +43,9 @@ fn connect(pre: &path, post: &path) -> path {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_is_dir(p: &path) -> bool {
|
fn file_is_dir(p: &path) -> bool {
|
||||||
ret rustrt::rust_file_is_dir(istr::to_estr(p)) != 0;
|
ret istr::as_buf(p, { |buf|
|
||||||
|
rustrt::rust_file_is_dir(buf) != 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_dir(p: &path) -> [istr] {
|
fn list_dir(p: &path) -> [istr] {
|
||||||
|
|
|
@ -444,9 +444,9 @@ rust_dirent_filename(rust_task *task, dirent* ent) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" CDECL int
|
extern "C" CDECL int
|
||||||
rust_file_is_dir(rust_task *task, rust_str *path) {
|
rust_file_is_dir(rust_task *task, char *path) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (stat((char*)path->data, &buf)) {
|
if (stat(path, &buf)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return S_ISDIR(buf.st_mode);
|
return S_ISDIR(buf.st_mode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue