Implement getFileList()
This commit is contained in:
parent
e173780893
commit
b0e5f28528
1 changed files with 21 additions and 5 deletions
|
@ -3,11 +3,13 @@ use std::fmt::Display;
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
use std::fmt::Result as FMTResult;
|
use std::fmt::Result as FMTResult;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::vec::Vec;
|
||||||
|
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
|
use glob::Paths;
|
||||||
|
|
||||||
use super::file::FileID;
|
use storage::file::{File, FileID};
|
||||||
use super::file::File;
|
|
||||||
use module::Module;
|
use module::Module;
|
||||||
|
|
||||||
type BackendOperationResult = Result<(), StorageBackendError>;
|
type BackendOperationResult = Result<(), StorageBackendError>;
|
||||||
|
@ -26,9 +28,23 @@ impl<'a> StorageBackend<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getFileList(&self) -> Option<Vec<(Path, FileID)>> {
|
fn getFileList(&self) -> Option<Vec<FileID>> {
|
||||||
let files: Vec<&Path> = glob(&self.basepath[..]);
|
let list = glob(&self.basepath[..]);
|
||||||
files.map(|path| (path, file_id_from_path(path))).unwrap_or(None)
|
|
||||||
|
if let Ok(globlist) = list {
|
||||||
|
let mut v = vec![];
|
||||||
|
for entry in globlist {
|
||||||
|
if let Ok(path) = entry {
|
||||||
|
v.push(file_id_from_path(path.as_path()));
|
||||||
|
} else {
|
||||||
|
// Entry is not a path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(v)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn createEmpty() -> FileID {
|
fn createEmpty() -> FileID {
|
||||||
|
|
Loading…
Reference in a new issue