From 904d81595bbad52135164f3e05cfc10d78b7ec89 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 23 Jun 2016 14:16:05 +0200 Subject: [PATCH] Impl Ref::fs_file() --- libimagref/src/reference.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 1301d19a..7655cc1b 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -239,8 +239,13 @@ impl<'a> Ref<'a> { } /// Get the path of the file which is reffered to by this Ref - pub fn fs_file(&self) -> &PathBuf { - unimplemented!() + pub fn fs_file(&self) -> Result { + match self.0.get_header().read("ref.path") { + Ok(Some(Value::String(ref s))) => Ok(PathBuf::from(s)), + Ok(Some(_)) => Err(REK::HeaderTypeError.into_error()), + Ok(None) => Err(REK::HeaderFieldMissingError.into_error()), + Err(e) => Err(REK::StoreReadError.into_error_with_cause(Box::new(e))), + } } /// Check whether there is a reference to the file at `pb`