Sign in Join
FPDoc Onlineexperiment

MatchesWindowsMask function

In unit Masks

Indicates whether the file name matches the specified Windows-style file system mask.

Declaration

pascal
function MatchesWindowsMask(const FileName: string; const Mask: string; 
 CaseSensitive: Boolean=False; 
 aOpcodesAllowed: TMaskOpCodes=DefaultMaskOpCodes; 
 aWindowsQuirksAllowed: TWindowsQuirks=DefaultWindowsQuirks)
: Boolean

Arguments

FileName

File name compared to the mask value.

Mask

Mask used to perform the comparison.

CaseSensitiveTrue when case sensitivity should be used in the comparison.
aOpcodesAllowed
aWindowsQuirksAllowed

Function result

True when the file name matches the mask value using the specified options.

Description

MatchesWindowsMask is an overloaded Boolean function used to determine if the file name specified in FileName matches the specified Mask. Mask can contain a Windows-style file mask which uses the following wildcards:

foo*.*
Matches all files starting with 'foo' regardless of the file extension. Same as foo* using the Matches method.
foo*.
Matches foo* but must not include a file extension.
*.
Matches any file name, but must not include a file extension.
foo.
Matches foo but not foo.txt.
foo.*
Matches foo, foo.txt, or foo.bar.
*.*
Matches any file name with an extension.

CaseSensitive indicates whether case sensitivity is used when comparing the file name to the mask value.

Options contains a set of zero or more TMaskOption values enabled for the comparison. The Options argument allows enabling or disabling set notation in the mask value. Specifying moDisableSets in the Options parameter will disable interpreting the ' [' character as the beginning of a set in the specified mask. Use an empty set (' []') when options from the TMaskOption enumeration are not needed.

For example:

MatchesWindowsMask('[x]','[x]',[moDisableSets]);  // returns True

MatchesWindowsMask creates a TMask instance which is used to compare the file name to the mask using the specified options. Values in Mask and Options are passed as arguments the TMask constructor. The MatchesWindowsMask method in the TMask instance is called using FileName as an argument, and gets the return value for the function.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.