summaryrefslogtreecommitdiffstats
path: root/src/files.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-02-26 10:32:26 +0100
committerrabite <rabite@posteo.de>2019-02-26 10:32:26 +0100
commitb9a873094af7628ac682669730c68cf989763d8f (patch)
tree45a7f0a50a309131945dae58b9da2df1f7901f42 /src/files.rs
parent4c1e75c0580e763b66047423cdcd51d18b954e7f (diff)
don't rely on widget for cwd
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/files.rs b/src/files.rs
index c7896fb..f546a00 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -271,7 +271,7 @@ impl File {
}
}
- pub fn new_from_path(path: &Path) -> Result<File, Error> {
+ pub fn new_from_path(path: &Path) -> HResult<File> {
let pathbuf = path.to_path_buf();
let name = path
.file_name()
@@ -353,6 +353,11 @@ impl File {
Some(self.path.parent()?.parent()?.to_path_buf())
}
+ pub fn grand_parent_as_file(&self) -> HResult<File> {
+ let pathbuf = self.grand_parent()?;
+ File::new_from_path(&pathbuf)
+ }
+
pub fn is_dir(&self) -> bool {
self.kind == Kind::Directory
}