extern crate glob;
use std::path::Path;
use glob::{glob_with,Paths,PatternError,MatchOptions};
pub trait Glob {
fn glob_with(&self, pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError>;
fn glob(&self, pattern: &str) -> Result<Paths, PatternError> {
self.glob_with(pattern, &MatchOptions::new())
}
fn rglob_with(&self, pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError> {
self.glob_with(&format!("**/{}", pattern), options)
}
fn rglob(&self, pattern: &str) -> Result<Paths, PatternError> {
self.rglob_with(pattern, &MatchOptions::new())
}
}
impl<P: AsRef<Path>> Glob for P {
fn glob_with(&self, pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError> {
glob_with(self.as_ref().join(pattern).to_str().unwrap(), options)
}
}