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
pub use self::os::{glob_t};
pub use self::os::{GLOB_APPEND};
pub use self::os::{GLOB_DOOFFS};
pub use self::os::{GLOB_ERR};
pub use self::os::{GLOB_MARK};
pub use self::os::{GLOB_NOCHECK};
pub use self::os::{GLOB_NOESCAPE};
pub use self::os::{GLOB_NOSORT};
pub use self::os::{GLOB_ABORTED};
pub use self::os::{GLOB_NOMATCH};
pub use self::os::{GLOB_NOSPACE};

use {NTStr, int_t, char_t};

#[cfg(target_os = "linux")]
#[path = "linux/mod.rs"]
mod os;

pub fn glob<T: NTStr>(pattern: &T, flags: int_t,
                      errfunc: Option<extern fn(arg1: *const char_t, arg2: int_t) -> int_t>,
                      pglob: &mut glob_t) -> int_t {
    extern {
        fn glob(pattern: *const char_t, flags: int_t,
                errfunc: Option<extern fn(arg1: *const char_t, arg2: int_t) -> int_t>,
                pglob: *mut glob_t) -> int_t;
    }
    unsafe { glob(pattern.as_ptr(), flags, errfunc, pglob as *mut _) }
}

pub fn globfree(pglob: &mut glob_t) {
    extern { fn globfree(pglob: *mut glob_t); }
    unsafe { globfree(pglob as *mut _) }
}