summaryrefslogtreecommitdiffstats
path: root/src/repository
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-08-23 09:54:49 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-08-26 12:30:21 +0200
commite40a49822f88695d2b9ef553855704d15b0d96d9 (patch)
tree62c710a4aa4121e969001ab2f053cd5ee9384627 /src/repository
parente1d767d06684f8c070c4ce6801776ed1170a3a00 (diff)
Add method to get all pkg.toml file contents for a path
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/repository')
-rw-r--r--src/repository/fs.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/repository/fs.rs b/src/repository/fs.rs
index a865f3f..c648126 100644
--- a/src/repository/fs.rs
+++ b/src/repository/fs.rs
@@ -106,6 +106,25 @@ impl FileSystemRepresentation {
Ok(fsr)
}
+
+ pub fn get_files_for<'a>(&'a self, path: &Path) -> Result<Vec<&'a String>> {
+ let mut res = Vec::with_capacity(10); // good enough
+
+ let mut curr_hm = &self.elements;
+ for elem in path.components() {
+ let elem = PathComponent::try_from(&elem)?;
+
+ match curr_hm.get(&elem) {
+ Some(Element::File(cont)) => res.push(cont),
+ Some(Element::Dir(hm)) => curr_hm = hm,
+ None => {
+ unimplemented!()
+ },
+ }
+ }
+
+ Ok(res)
+ }
}
fn is_pkgtoml(entry: &DirEntry) -> bool {