CompareFileExt function
Compares the extension in a file name to a given value and returns the relative order.
Declaration
function CompareFileExt(const Filename: string; Ext: string;
CaseSensitive: Boolean): IntegerDescription
CompareFileExt is an overloaded
Integer function used
to compare the file extension in Filename to the value in Ext.
FilenameM contains the file name with the extension compared in
the routine.
Ext contains the file extension for the comparison. It may contain
the '.' character, but it is not required and will be removed for the
comparison.
CaseSensitive indicates whether case is used in the comparison.
When CaseSensitive contains
True, CompareStr is called to perform the
comparison. Otherwise, CompareText is called to compare the values.
The return value indicates the order for the file name extension relative to the specified extension. It may contain one of the following values:
- -1
- Filename value has a lower sort order value than Ext
- 0
- Filename and Ext have the same sort order values
- 1
- Filename value has a higher sort order value than Ext
The return value is 1 if Filename does not contain a file extension.
The overloaded variant which omits the CaseSensitive argument defaults to
the setting for the CaseInsensitiveFilenames compiler define on
the platform. When defined, the CaseSensitive argument defaults to
False. Otherwise, True is used in the parameter value.
An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
