diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2018-12-01 11:59:51 -0800 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2018-12-01 11:59:51 -0800 |
| commit | 8f33ac391863f4acc5eada1a99642f540db5a334 (patch) | |
| tree | eafbbc81b7fea94d75affa9206f3f6d48b99e7b2 | |
| parent | f428a84b1668326bcd57703fa7dfb1cd1520af84 (diff) | |
| download | plag-8f33ac391863f4acc5eada1a99642f540db5a334.tar.gz plag-8f33ac391863f4acc5eada1a99642f540db5a334.zip | |
Add path property
| -rw-r--r-- | src/main.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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<f64> { 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<Feature> { 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); |
