INNER CODE UNIT · Rust
view_passed_files
atanunq/viu · src/app.rs:67
fn view_passed_files(conf: &mut Config, (tx, rx): TxRx) -> ViuResult {
//loop throught all files passed
for filename in &conf.files {
//check if Ctrl-C has been received. If yes, stop iterating
if rx.try_recv().is_ok() {
return tx
.send(true)
.map_err(|_| Error::other("Could not send signal to clean up.").into());
};
//if it's a directory, stop gif looping because there will probably be more files
if fs::metadata(filename)?.is_dir() {
conf.loop_gif = false;
view_directory(conf, filename, (tx, rx))?;
}
//if a file has been passed individually and fails, propagate the error
else {
view_file(conf, filename, (tx, rx))?;
}