mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-24 11:38:33 +02: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 {
|
let reader: Box<BufRead> = match filename {
|
||||||
InputFile::StdIn => Box::new(stdin.lock()),
|
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),
|
InputFile::ThemePreviewFile => Box::new(THEME_PREVIEW_FILE),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user