diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-10-04 18:19:59 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-10-04 18:20:22 -0700 |
| commit | 9698ef89a0c5513b9670f6ec56ea06de5728eb5a (patch) | |
| tree | f722d9a6b545e470f5e0ed2dc8e5e0017029dac5 /src | |
| parent | 990233eb3d0b8b609a861f137c91cc5d6163265b (diff) | |
| download | rust-9698ef89a0c5513b9670f6ec56ea06de5728eb5a.tar.gz rust-9698ef89a0c5513b9670f6ec56ea06de5728eb5a.zip | |
stdlib: Migrate rust_file_is_dir() over to the C stack, and add a void type
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/fs.rs | 9 | ||||
| -rw-r--r-- | src/lib/util.rs | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/fs.rs b/src/lib/fs.rs index 06243b6d3aa..a2e81184d01 100644 --- a/src/lib/fs.rs +++ b/src/lib/fs.rs @@ -1,9 +1,10 @@ import os::getcwd; +import util::void; import os_fs; -native "rust" mod rustrt { - fn rust_file_is_dir(path: str::sbuf) -> int; +native "c-stack-cdecl" mod rustrt { + fn rust_file_is_dir(unused: *void, path: *u8) -> int; } fn path_sep() -> str { ret str::from_char(os_fs::path_sep); } @@ -52,7 +53,9 @@ fn connect_many(paths: [path]) : vec::is_not_empty(paths) -> path { } fn file_is_dir(p: path) -> bool { - ret str::as_buf(p, {|buf| rustrt::rust_file_is_dir(buf) != 0 }); + ret str::as_buf(p, { + |buf| rustrt::rust_file_is_dir(ptr::null(), buf) != 0 + }); } fn list_dir(p: path) -> [str] { diff --git a/src/lib/util.rs b/src/lib/util.rs index 1d9c28d99e4..eb1790f569d 100644 --- a/src/lib/util.rs +++ b/src/lib/util.rs @@ -17,6 +17,13 @@ pure fn rational_leq(x: rational, y: rational) -> bool { } pure fn orb(a: bool, b: bool) -> bool { a || b } + +// An unconstructible type. Currently we're using this for unused parameters +// in native functions, but it may be useful for other purposes as well. +tag void { + void(@void); +} + // Local Variables: // mode: rust; // fill-column: 78; |
