diff options
| author | bors <bors@rust-lang.org> | 2013-09-05 22:00:58 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-05 22:00:58 -0700 |
| commit | 5efe1e536575b61d0e8022a71c3f10d993fa1d00 (patch) | |
| tree | deaa1835a392fa8793d5debf57f0411431ab3a9f /src/libstd | |
| parent | f05119673125efdd86ab53765d4571b5e757cf3a (diff) | |
| parent | 193a1c8af6a0ceef734fff9acc07231c67896bb1 (diff) | |
| download | rust-5efe1e536575b61d0e8022a71c3f10d993fa1d00.tar.gz rust-5efe1e536575b61d0e8022a71c3f10d993fa1d00.zip | |
auto merge of #8914 : Dretch/rust/native-glob, r=alexcrichton
This is #8201 with a bunch of amendments to address the comments (and re-based).
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/os.rs | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 0d77748b203..ffd99fc9f75 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1318,90 +1318,6 @@ pub fn args() -> ~[~str] { real_args() } -// FIXME #6100 we should really use an internal implementation of this - using -// the POSIX glob functions isn't portable to windows, probably has slight -// inconsistencies even where it is implemented, and makes extending -// functionality a lot more difficult -// FIXME #6101 also provide a non-allocating version - each_glob or so? -/// Returns a vector of Path objects that match the given glob pattern -#[cfg(target_os = "linux")] -#[cfg(target_os = "android")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "macos")] -pub fn glob(pattern: &str) -> ~[Path] { - #[fixed_stack_segment]; #[inline(never)]; - - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] - fn default_glob_t () -> libc::glob_t { - libc::glob_t { - gl_pathc: 0, - gl_pathv: ptr::null(), - gl_offs: 0, - __unused1: ptr::null(), - __unused2: ptr::null(), - __unused3: ptr::null(), - __unused4: ptr::null(), - __unused5: ptr::null(), - } - } - - #[cfg(target_os = "freebsd")] - fn default_glob_t () -> libc::glob_t { - libc::glob_t { - gl_pathc: 0, - __unused1: 0, - gl_offs: 0, - __unused2: 0, - gl_pathv: ptr::null(), - __unused3: ptr::null(), - __unused4: ptr::null(), - __unused5: ptr::null(), - __unused6: ptr::null(), - __unused7: ptr::null(), - __unused8: ptr::null(), - } - } - - #[cfg(target_os = "macos")] - fn default_glob_t () -> libc::glob_t { - libc::glob_t { - gl_pathc: 0, - __unused1: 0, - gl_offs: 0, - __unused2: 0, - gl_pathv: ptr::null(), - __unused3: ptr::null(), - __unused4: ptr::null(), - __unused5: ptr::null(), - __unused6: ptr::null(), - __unused7: ptr::null(), - __unused8: ptr::null(), - } - } - - let mut g = default_glob_t(); - do pattern.with_c_str |c_pattern| { - unsafe { libc::glob(c_pattern, 0, ptr::null(), &mut g) } - }; - do(|| { - let paths = unsafe { - vec::raw::from_buf_raw(g.gl_pathv, g.gl_pathc as uint) - }; - do paths.map |&c_str| { - Path(unsafe { str::raw::from_c_str(c_str) }) - } - }).finally { - unsafe { libc::globfree(&mut g) }; - } -} - -/// Returns a vector of Path objects that match the given glob pattern -#[cfg(target_os = "win32")] -pub fn glob(_pattern: &str) -> ~[Path] { - fail!("glob() is unimplemented on Windows") -} - #[cfg(target_os = "macos")] extern { // These functions are in crt_externs.h. |
