about summary refs log tree commit diff
path: root/src/libstd/posix_fs.rs
blob: e774650f980b5b208fc585e03865a0d6603ea880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#[abi = "cdecl"]
native mod rustrt {
    fn rust_list_files(path: str) -> [str];
}

fn list_dir(path: str) -> [str] {
    ret rustrt::rust_list_files(path);

    // 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);
    let vec<str> result = [];
    while (true) {
        auto ent = os::libc::readdir(dir);
        if (ent as int == 0) {
            os::libc::closedir(dir);
            ret result;
        }
        vec::push::<str>(result, rustrt::rust_dirent_filename(ent));
    }
    os::libc::closedir(dir);
    ret result;
    */

}

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

const path_sep: char = '/';

const alt_path_sep: char = '/';

// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End: