2011-11-16 22:49:38 -06:00
|
|
|
#[abi = "cdecl"]
|
|
|
|
native mod rustrt {
|
2011-10-20 10:18:39 -07:00
|
|
|
fn rust_list_files(path: str) -> [str];
|
2011-03-10 15:56:51 +01:00
|
|
|
}
|
|
|
|
|
2011-09-12 11:27:30 +02:00
|
|
|
fn list_dir(path: str) -> [str] {
|
2011-09-01 15:51:27 -07:00
|
|
|
ret rustrt::rust_list_files(path);
|
2011-06-15 11:19:50 -07:00
|
|
|
|
|
|
|
// FIXME: No idea why, but this appears to corrupt memory on OSX. I
|
|
|
|
// suspect it has to do with the tasking primitives somehow, or perhaps
|
|
|
|
// the FFI. Worth investigating more when we're digging into the FFI and
|
|
|
|
// unsafe mode in more detail; in the meantime we just call list_files
|
|
|
|
// above and skip this code.
|
|
|
|
|
|
|
|
/*
|
|
|
|
auto dir = os::libc::opendir(str::buf(path));
|
|
|
|
assert (dir as uint != 0u);
|
2011-08-10 09:27:11 -07:00
|
|
|
let vec<str> result = [];
|
2011-06-15 11:19:50 -07:00
|
|
|
while (true) {
|
|
|
|
auto ent = os::libc::readdir(dir);
|
|
|
|
if (ent as int == 0) {
|
|
|
|
os::libc::closedir(dir);
|
|
|
|
ret result;
|
|
|
|
}
|
2011-08-12 10:56:57 -07:00
|
|
|
vec::push::<str>(result, rustrt::rust_dirent_filename(ent));
|
2011-06-15 11:19:50 -07:00
|
|
|
}
|
|
|
|
os::libc::closedir(dir);
|
|
|
|
ret result;
|
|
|
|
*/
|
|
|
|
|
2011-03-10 15:56:51 +01:00
|
|
|
}
|
|
|
|
|
2011-12-16 18:18:34 +01:00
|
|
|
// FIXME make pure when str::char_at is
|
2011-09-12 11:27:30 +02:00
|
|
|
fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/'; }
|
2011-06-17 15:52:37 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
const path_sep: char = '/';
|
2011-03-16 14:58:02 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
const alt_path_sep: char = '/';
|
2011-06-17 11:12:51 -07:00
|
|
|
|
2011-03-16 14:58:02 -07:00
|
|
|
// Local Variables:
|
|
|
|
// mode: rust;
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// End:
|