summaryrefslogtreecommitdiff
path: root/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/main.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 0a2b94eb..eaa429c7 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -2,7 +2,7 @@ use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::fs::{self, File};
use std::hash::Hash;
-use std::io::{self, Read, Write};
+use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process;
@@ -559,11 +559,8 @@ impl PathHash {
/// Read a file.
fn read(path: &Path) -> FileResult<Vec<u8>> {
let f = |e| FileError::from_io(e, path);
- let mut file = File::open(path).map_err(f)?;
- if file.metadata().map_err(f)?.is_file() {
- let mut data = vec![];
- file.read_to_end(&mut data).map_err(f)?;
- Ok(data)
+ if fs::metadata(&path).map_err(f)?.is_file() {
+ fs::read(&path).map_err(f)
} else {
Err(FileError::IsDirectory)
}