Add StorageBackend::iter_ids()

This commit is contained in:
Matthias Beyer 2015-12-02 11:41:49 +01:00
parent d22b991da0
commit 1b6711fe10

View file

@ -8,6 +8,7 @@ use std::vec::Vec;
use std::fs::File as FSFile;
use std::io::Read;
use std::io::Write;
use std::vec::IntoIter;
use glob::glob;
use glob::Paths;
@ -61,6 +62,17 @@ impl StorageBackend {
}
}
pub fn iter_ids(&self, m: &Module) -> Option<IntoIter<FileID>>
{
glob(&self.prefix_of_files_for_module(m)[..]).and_then(|globlist| {
let v = globlist.filter_map(Result::ok)
.map(|pbuf| from_pathbuf(&pbuf))
.collect::<Vec<FileID>>()
.into_iter();
Ok(v)
}).ok()
}
/*
* Write a file to disk.
*