2
0
mirror of https://github.com/sharkdp/bat synced 2024-11-18 15:26:16 +00:00

add quotes around filename

and make it more concise by using map_err
This commit is contained in:
ufuji1984 2018-12-12 05:55:11 +09:00 committed by David Peter
parent 549e5d7355
commit 4ff360669f

View File

@ -59,10 +59,7 @@ impl<'a> InputFile<'a> {
match self { match self {
InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())), InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())),
InputFile::Ordinary(filename) => { InputFile::Ordinary(filename) => {
let file = match File::open(filename) { let file = File::open(filename).map_err(|e| format!("'{}': {}", filename, e))?;
Ok(f) => f,
Err(e) => return Err(format!("{}: {}", filename, e).into()),
};
if file.metadata()?.is_dir() { if file.metadata()?.is_dir() {
return Err(format!("'{}' is a directory.", filename).into()); return Err(format!("'{}' is a directory.", filename).into());