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:
parent
549e5d7355
commit
4ff360669f
@ -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());
|
||||||
|
Loading…
Reference in New Issue
Block a user