posix_fs.rs 1.2 KB
Newer Older
1 2
#[abi = "cdecl"]
native mod rustrt {
3
    fn rust_list_files(path: str) -> [str];
4 5
}

6
fn list_dir(path: str) -> [str] {
7
    ret rustrt::rust_list_files(path);
8 9 10 11 12 13 14 15 16 17

    // 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);
18
    let vec<str> result = [];
19 20 21 22 23 24
    while (true) {
        auto ent = os::libc::readdir(dir);
        if (ent as int == 0) {
            os::libc::closedir(dir);
            ret result;
        }
25
        vec::push::<str>(result, rustrt::rust_dirent_filename(ent));
26 27 28 29 30
    }
    os::libc::closedir(dir);
    ret result;
    */

31 32
}

33
// FIXME make pure when str::char_at is
34
fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/'; }
35

M
Marijn Haverbeke 已提交
36
const path_sep: char = '/';
37

M
Marijn Haverbeke 已提交
38
const alt_path_sep: char = '/';
39

40 41 42 43 44 45 46
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End: