Add basic directory listing & config reading

main
Del 2021-08-02 15:52:56 +00:00
parent 1bee9f225d
commit 7d1cdcbdb1
Signed by: del
GPG Key ID: 4370F2F5792B6C1F
1 changed files with 16 additions and 6 deletions

View File

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::{env, fs};
#[derive(Debug, Serialize, Deserialize)]
@ -20,10 +21,19 @@ fn main() {
let conf : Config = serde_yaml::from_str(&conf_str)
.expect("invalid config format");
let input_paths = fs::read_dir(conf.input_path).unwrap();
for path in input_paths {
println!("{}", path.unwrap().path().display())
}
load_paths(&conf.input_path).unwrap();
}
fn load_paths(root_dir : &str) -> Result<(), Box<dyn Error>> {
let entries = fs::read_dir(root_dir)?;
for entry in entries {
let entry = entry?;
let meta = entry.metadata()?;
if meta.is_file() {
println!("{}", entry.path().display());
}
}
Ok(())
}