ignore: polish

Like previous commits, we do a bit of polishing and bring the style up
to my current practice.
This commit is contained in:
Andrew Gallant
2023-09-28 14:17:30 -04:00
parent be9e308999
commit f16ea0812d
12 changed files with 215 additions and 220 deletions

View File

@@ -1,10 +1,6 @@
use std::env;
use std::io::{self, Write};
use std::path::Path;
use std::thread;
use std::{env, io::Write, path::Path};
use ignore::WalkBuilder;
use walkdir::WalkDir;
use {bstr::ByteVec, ignore::WalkBuilder, walkdir::WalkDir};
fn main() {
let mut path = env::args().nth(1).unwrap();
@@ -19,10 +15,11 @@ fn main() {
simple = true;
}
let stdout_thread = thread::spawn(move || {
let mut stdout = io::BufWriter::new(io::stdout());
let stdout_thread = std::thread::spawn(move || {
let mut stdout = std::io::BufWriter::new(std::io::stdout());
for dent in rx {
write_path(&mut stdout, dent.path());
stdout.write(&*Vec::from_path_lossy(dent.path())).unwrap();
stdout.write(b"\n").unwrap();
}
});
@@ -65,16 +62,3 @@ impl DirEntry {
}
}
}
#[cfg(unix)]
fn write_path<W: Write>(mut wtr: W, path: &Path) {
use std::os::unix::ffi::OsStrExt;
wtr.write(path.as_os_str().as_bytes()).unwrap();
wtr.write(b"\n").unwrap();
}
#[cfg(not(unix))]
fn write_path<W: Write>(mut wtr: W, path: &Path) {
wtr.write(path.to_string_lossy().as_bytes()).unwrap();
wtr.write(b"\n").unwrap();
}