Skip to main content

base_plus_ext

Function base_plus_ext 

Source
pub fn base_plus_ext(path: &str) -> Option<(&str, &str)>
Expand description

Split a path into its basename and its full extension.

The basename is everything up to the first dot after the last slash; the extension is everything after it. Files in a WebDataset share a basename exactly when they belong to the same sample.

use webdataset_core::utils::base_plus_ext;

assert_eq!(base_plus_ext("a/b/c.png"), Some(("a/b/c", "png")));
assert_eq!(base_plus_ext("a/b/c.seg.png"), Some(("a/b/c", "seg.png")));
assert_eq!(base_plus_ext("noextension"), None);