[all (rust)] Fix errors in testing input option

- Fix file mode bits checking
- Return error reason from stat
This commit is contained in:
Ming-Hung Tsai
2021-09-07 00:01:37 +08:00
parent 4ed2348b36
commit 2f22a8c55d
13 changed files with 85 additions and 53 deletions

View File

@ -5,7 +5,6 @@ use atty::Stream;
use clap::{App, Arg};
use std::path::Path;
use std::process;
use std::process::exit;
use std::sync::Arc;
use thinp::file_utils;
use thinp::io_engine::*;
@ -80,9 +79,9 @@ fn main() {
let matches = parser.get_matches();
let input_file = Path::new(matches.value_of("INPUT").unwrap());
if !file_utils::file_exists(input_file) {
eprintln!("Couldn't find input file '{:?}'.", &input_file);
exit(1);
if let Err(e) = file_utils::is_file_or_blk(input_file) {
eprintln!("Invalid input file '{}': {}.", input_file.display(), e);
process::exit(1);
}
let report;