diff --git a/libimagstore/src/error.rs b/libimagstore/src/error.rs index cdb21a41..4ad9c5f2 100644 --- a/libimagstore/src/error.rs +++ b/libimagstore/src/error.rs @@ -33,6 +33,8 @@ pub enum StoreErrorKind { PreHookExecuteError, PostHookExecuteError, StorePathLacksVersion, + GlobError, + EncodingError, // maybe more } @@ -62,6 +64,8 @@ fn store_error_type_as_str(e: &StoreErrorKind) -> &'static str { &StoreErrorKind::PreHookExecuteError => "Pre-Hook execution error", &StoreErrorKind::PostHookExecuteError => "Post-Hook execution error", &StoreErrorKind::StorePathLacksVersion => "The supplied store path has no version part", + &StoreErrorKind::GlobError => "glob() error", + &StoreErrorKind::EncodingError => "Encoding error", } } diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 9fa62d73..201386d5 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -17,6 +17,7 @@ use toml::{Table, Value}; use regex::Regex; use crossbeam; use crossbeam::ScopedJoinHandle; +use glob::glob; use error::{ParserErrorKind, ParserError}; use error::{StoreError, StoreErrorKind}; @@ -307,8 +308,19 @@ impl Store { } /// Iterate over all StoreIds for one module name - pub fn retrieve_for_module(&self, mod_name: &str) -> StoreIdIterator { - unimplemented!(); + pub fn retrieve_for_module(&self, mod_name: &str) -> Result { + let mut path = self.path().clone(); + path.push(mod_name); + + if let Some(path) = path.to_str() { + let path = [ path, "/*" ].join(""); + debug!("glob()ing with '{}'", path); + glob(&path[..]) + .map(StoreIdIterator::new) + .map_err(|e| StoreError::new(StoreErrorKind::GlobError, Some(Box::new(e)))) + } else { + Err(StoreError::new(StoreErrorKind::EncodingError, None)) + } } /// Return the `FileLockEntry` and write to disk