From 8f33ac391863f4acc5eada1a99642f540db5a334 Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Sat, 1 Dec 2018 11:59:51 -0800 Subject: Add path property --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d031496..1076441 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,12 +125,14 @@ fn get_longitude(reader: &exif::Reader) -> Result { enum Property { Filename, + Path, } impl std::fmt::Display for Property { fn fmt(&self, w: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Property::Filename => write!(w, "filename"), + Property::Path => write!(w, "path"), } } } @@ -149,7 +151,11 @@ fn get_feature(filename: &Path, properties: &[Property]) -> Result { for prop in properties { let key = prop.to_string(); let value = match prop { - Property::Filename => to_value(filename.file_name().unwrap().to_string_lossy()) + Property::Filename => to_value(filename.file_name().unwrap().to_string_lossy()), + Property::Path => { + let path = filename.canonicalize()?; + to_value(path.to_string_lossy()) + } }; props.insert(key, value.unwrap()); } @@ -189,6 +195,7 @@ fn main() { for prop in requested_properties { match prop { "filename" => valid_properties.push(Property::Filename), + "path" => valid_properties.push(Property::Path), _ => { eprintln!("unknown property: {}", prop); std::process::exit(1); -- cgit v1.2.3