mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-20 20:08:58 +00:00
Do not show file header for directories
This also adds a better error message. closes #292
This commit is contained in:
parent
ea369ee17f
commit
e098eb43a2
@ -53,7 +53,15 @@ impl<'b> Controller<'b> {
|
||||
{
|
||||
let reader: Box<BufRead> = match filename {
|
||||
InputFile::StdIn => Box::new(stdin.lock()),
|
||||
InputFile::Ordinary(filename) => Box::new(BufReader::new(File::open(filename)?)),
|
||||
InputFile::Ordinary(filename) => {
|
||||
let file = File::open(filename)?;
|
||||
|
||||
if file.metadata()?.is_dir() {
|
||||
return Err(format!("'{}' is a directory.", filename).into());
|
||||
}
|
||||
|
||||
Box::new(BufReader::new(file))
|
||||
}
|
||||
InputFile::ThemePreviewFile => Box::new(THEME_PREVIEW_FILE),
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user