Initial Commit
This commit is contained in:
27
src/local.rs
Normal file
27
src/local.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use crate::FileList;
|
||||
use crate::Opt;
|
||||
use chrono::DateTime;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs::*;
|
||||
|
||||
pub fn file_list(opt: &Opt) -> anyhow::Result<FileList> {
|
||||
let mut list = BTreeMap::new();
|
||||
|
||||
for entry in read_dir(&opt.path)? {
|
||||
let entry = entry?;
|
||||
|
||||
if !entry.file_type()?.is_dir() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name = match entry.file_name().into_string() {
|
||||
Ok(name) => name,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
let date = DateTime::parse_from_rfc3339(&name)?;
|
||||
list.insert(date, name);
|
||||
}
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
Reference in New Issue
Block a user