1234567891011121314151617181920212223242526272829303132333435363738394041424344 | '\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH Path.has_extension 3 2026-09-01 "Tomo man-pages"
.SH NAME
Path.has_extension \- check if a path has a given extension
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Path.has_extension\ :\ func(path:\ Path,\ extension:\ Text\ ->\ Bool)
.fi
.SH DESCRIPTION
Return whether or not a path has a given file extension. Unlike `Path.extension`, this reads the raw bytes of the name and so works on names that are not valid UTF-8.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx
l l l.
Name Type Description
path Path A path.
extension Text A file extension (leading \fB.\fR is optional). If empty, the check will test if the file does not have any file extension.
.TE
.SH RETURN
Whether or not the path has the given extension.
.SH EXAMPLES
.EX
assert (/foo.txt).has_extension("txt")
assert (/foo.txt).has_extension(".txt")
assert (/foo.tar.gz).has_extension("gz")
assert not (/foo.tar.gz).has_extension("zip")
# Asking for an empty extension is the same question as `.extension()`
# being `none`, for any name that is valid UTF-8:
assert (/foo).has_extension("")
assert (/).has_extension("")
.EE
.SH SEE ALSO
.BR Tomo-Path (3)
|