Iterating over directories.
This commit is contained in:
parent
61267f4443
commit
3ccc66b5d7
@ -6,3 +6,4 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
walkdir = "2.3.2"
|
||||||
|
20
src/main.rs
20
src/main.rs
@ -1,3 +1,21 @@
|
|||||||
|
use std::{env, fs::FileType};
|
||||||
|
use walkdir::DirEntry;
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
let mut args = env::args();
|
||||||
|
let _program = args.next().expect("argv[0] should be this program?");
|
||||||
|
let profile = args.next().expect("Must provide a profile");
|
||||||
|
let directories: Vec<String> = args.collect();
|
||||||
|
|
||||||
|
let mut files: Vec<DirEntry> = Vec::new();
|
||||||
|
for dir in directories {
|
||||||
|
for entry in WalkDir::new(dir) {
|
||||||
|
let entry = entry.unwrap();
|
||||||
|
if entry.file_type().is_file() {
|
||||||
|
eprintln!("{}", entry.path().display());
|
||||||
|
files.push(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user