diff options
author | Canop <cano.petrole@gmail.com> | 2022-03-27 20:48:30 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2022-03-27 20:48:30 +0200 |
commit | a697c79919301313a6942808363f5a9483c3b1d7 (patch) | |
tree | e5d718af7d3a67028302411c7206fbc8a1d41c2f /src/app/selection.rs | |
parent | a9c90d1d98d52db4e27f0484303dc157b431519c (diff) |
verb filtering by file extension
Fix #508
Diffstat (limited to 'src/app/selection.rs')
-rw-r--r-- | src/app/selection.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/app/selection.rs b/src/app/selection.rs index eebd791..f435dcb 100644 --- a/src/app/selection.rs +++ b/src/app/selection.rs @@ -124,4 +124,24 @@ impl<'a> SelInfo<'a> { _ => None, } } + pub fn extension(&self) -> Option<&str> { + match self { + SelInfo::None => None, + SelInfo::One(sel) => sel.path.extension().and_then(|e| e.to_str()), + SelInfo::More(stage) => { + let common_extension = stage.paths()[0] + .extension().and_then(|e| e.to_str()); + if common_extension.is_none() { + return None; + } + for path in stage.paths().iter().skip(1) { + let extension = path.extension().and_then(|e| e.to_str()); + if extension != common_extension { + return None; + } + } + common_extension + } + } + } } |