dirwalk 1.1.1

Platform-optimized recursive directory walker with metadata
Documentation
use crate::entry::Entry;
use std::borrow::Borrow;
use std::io::{self, Write};

pub fn write<E: Borrow<Entry>>(w: &mut impl Write, entries: &[E]) -> io::Result<()> {
    let mut wtr = csv::Writer::from_writer(w);
    wtr.write_record([
        "name",
        "relative_path",
        "depth",
        "size",
        "is_dir",
        "is_symlink",
        "is_hidden",
        "modified",
        "extension",
    ])?;
    for e in entries {
        let entry: &Entry = e.borrow();
        wtr.write_record([
            entry.name(),
            &entry.relative_path,
            &entry.depth.to_string(),
            &entry.size.to_string(),
            &entry.is_dir.to_string(),
            &entry.is_symlink.to_string(),
            &entry.is_hidden.to_string(),
            &entry.modified.to_string(),
            entry.extension().unwrap_or(""),
        ])?;
    }
    wtr.flush()?;
    Ok(())
}