diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-06-24 13:37:09 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-06-24 13:37:09 -0400 |
| commit | 271017ba9970e4220e1bd0dc83ce146afe9222a2 (patch) | |
| tree | 995233d21141f164aa5f9e1d9b7bab757124e622 /api/paths.md | |
| parent | e122e5525ef044c25c2cd888bc267f7a2bd91b4f (diff) | |
Add Path.has_extension() and update manpages/api docs
Diffstat (limited to 'api/paths.md')
| -rw-r--r-- | api/paths.md | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/api/paths.md b/api/paths.md index ad6b894b..aade9b0f 100644 --- a/api/paths.md +++ b/api/paths.md @@ -489,6 +489,34 @@ follow_symlinks | `Bool` | Whether to follow symbolic links. | `yes` = 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 ```tomo |
