|
|
@ -1,6 +1,6 @@
|
|
|
|
|
|
|
|
use std::ffi::OsStr;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{self, BufRead, BufReader};
|
|
|
|
use std::io::{self, BufRead, BufReader};
|
|
|
|
use std::ffi::OsStr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use content_inspector::{self, ContentType};
|
|
|
|
use content_inspector::{self, ContentType};
|
|
|
|
|
|
|
|
|
|
|
@ -64,7 +64,8 @@ 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 = File::open(filename).map_err(|e| format!("'{}': {}", filename.to_string_lossy(), e))?;
|
|
|
|
let file = File::open(filename)
|
|
|
|
|
|
|
|
.map_err(|e| format!("'{}': {}", filename.to_string_lossy(), e))?;
|
|
|
|
|
|
|
|
|
|
|
|
if file.metadata()?.is_dir() {
|
|
|
|
if file.metadata()?.is_dir() {
|
|
|
|
return Err(format!("'{}' is a directory.", filename.to_string_lossy()).into());
|
|
|
|
return Err(format!("'{}' is a directory.", filename.to_string_lossy()).into());
|
|
|
|