blob: b1f01a66414c45f07089f0726fc6cbd83978c5c9 (
plain) (
blame)
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
|
native "rust" mod rustrt {
fn rust_dirent_filename(OS.libc.dirent ent) -> str;
}
fn list_dir(str path) -> vec[str] {
// TODO ensure this is always closed
auto dir = OS.libc.opendir(Str.buf(path));
assert (dir as uint != 0u);
let vec[str] result = vec();
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;
}
const char path_sep = '/';
const char alt_path_sep = '/';
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
|