mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-26 20:16:31 +00:00
fix: throw an error when try to view a directory
This commit is contained in:
2 files changed
+14
-1
No files matched your search
@@ -1,3 +1,9 @@
|
||||
# unreleased
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Throw an error when try to view a directory, see #234 (@Integral-Tech)
|
||||
|
||||
# v0.15.0
|
||||
|
||||
## Features
|
||||
|
||||
+8
-1
@@ -234,7 +234,14 @@ fn run() -> Result<()> {
|
||||
let stdin = io::stdin();
|
||||
|
||||
let mut reader = match opt.file {
|
||||
Some(filename) => Input::File(File::open(filename)?),
|
||||
Some(filename) => {
|
||||
let file = File::open(&filename)?;
|
||||
if file.metadata()?.is_dir() {
|
||||
return Err(anyhow!("{} is a directory.", filename.display()));
|
||||
}
|
||||
|
||||
Input::File(file)
|
||||
}
|
||||
None => Input::Stdin(stdin.lock()),
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user