From 271017ba9970e4220e1bd0dc83ce146afe9222a2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 Jun 2025 13:37:09 -0400 Subject: Add Path.has_extension() and update manpages/api docs --- api/paths.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'api/paths.md') diff --git a/api/paths.md b/api/paths.md index ad6b894b..aade9b0f 100644 --- a/api/paths.md +++ b/api/paths.md @@ -488,6 +488,34 @@ follow_symlinks | `Bool` | Whether to follow symbolic links. | `yes` >> (/non/existent/file).group() = none +``` +## Path.has_extension + +```tomo +Path.has_extension : func(path: Path, extension: Text -> Bool) +``` + +Return whether or not a path has a given file extension. + +Argument | Type | Description | Default +---------|------|-------------|--------- +path | `Path` | A path. | - +extension | `Text` | A file extension (leading `.` is optional). If empty, the check will test if the file does not have any file extension. | - + +**Return:** Whether or not the path has the given extension. + + +**Example:** +```tomo +>> (/foo.txt).has_extension("txt") += yes +>> (/foo.txt).has_extension(".txt") += yes +>> (/foo.tar.gz).has_extension("gz") += yes +>> (/foo.tar.gz).has_extension("zip") += no + ``` ## Path.is_directory -- cgit v1.2.3