summaryrefslogtreecommitdiffstats
path: root/src/files.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-02-16 15:01:46 +0100
committerrabite <rabite@posteo.de>2019-02-16 15:01:46 +0100
commit6802a764799120a715e1498d5b14aba69439b055 (patch)
tree522c1244713317668b6a9320235e684e579dafa3 /src/files.rs
parentf77178938cb015ce25fe522fa580efe6b429653e (diff)
async v3-beta
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/files.rs b/src/files.rs
index 03f0dc6..7d7b3e4 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -1,5 +1,4 @@
use std::cmp::{Ord, Ordering};
-use std::error::Error;
use std::ops::Index;
use std::os::unix::fs::MetadataExt;
use std::path::{Path, PathBuf};
@@ -8,6 +7,9 @@ use lscolors::LsColors;
use mime_detective;
use users;
use chrono::TimeZone;
+use failure::Error;
+
+use crate::fail::HError;
lazy_static! {
@@ -53,7 +55,7 @@ fn get_color(path: &Path, meta: &std::fs::Metadata) -> Option<lscolors::Color> {
}
impl Files {
- pub fn new_from_path(path: &Path) -> Result<Files, Box<dyn Error>> {
+ pub fn new_from_path(path: &Path) -> Result<Files, Error> {
let direntries: Result<Vec<_>, _> = std::fs::read_dir(&path)?.collect();
let files: Vec<_> = direntries?
@@ -244,7 +246,7 @@ impl File {
}
}
- pub fn new_from_path(path: &Path) -> Result<File, Box<Error>> {
+ pub fn new_from_path(path: &Path) -> Result<File, Error> {
let pathbuf = path.to_path_buf();
let name = path
.file_name()
@@ -265,7 +267,7 @@ impl File {
)
}
- pub fn new_placeholder(path: &Path) -> Result<File, Box<Error>> {
+ pub fn new_placeholder(path: &Path) -> Result<File, Error> {
let mut file = File::new_from_path(path)?;
file.name = "<empty>".to_string();
file.kind = Kind::Placeholder;
@@ -314,16 +316,8 @@ impl File {
self.kind == Kind::Directory
}
- pub fn read_dir(&self) -> Result<Files, Box<Error>> {
- match self.kind {
- Kind::Placeholder => {
- let e: Box<Error>
- = From::from("placeholder".to_string());
- Err(e)
- },
- _ => Files::new_from_path(&self.path)
- }
-
+ pub fn read_dir(&self) -> Result<Files, Error> {
+ Files::new_from_path(&self.path)
}