use crate::entry::Entry;
use std::io::{self, Write};
pub fn write(w: &mut impl Write, entries: &[&Entry]) -> 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 entry in entries {
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(())
}