pub fn suffixes(path: &str, fmt: PathFormat) -> Vec<String>Expand description
Get all suffixes (like Python’s PurePath.suffixes). “file.tar.gz” → [“.tar”, “.gz”] Get all suffixes (extensions) of the file name.
Matches Python pathlib’s algorithm:
name = self.name
if name.endswith('.'):
return []
name = name.lstrip('.')
return ['.' + suffix for suffix in name.split('.')[1:]]Notable corollaries:
- Trailing-dot names have no suffixes (
foo.→[]). - Names that consist entirely of leading dots (
.,..,...) yield[]becauselstrip('.')produces the empty string. .tar.gz(a name that is itself a suffix-looking filename) yields['.gz'], not['.tar', '.gz']— the leading-dot prefix is stripped before splitting...fooyields[]even thoughsuffixreturns.foo, becauselstrip('.')produces'foo'which has no inner dot. This is a pathlib quirk we preserve for parity.