FIX: Use normalized strings when compare file names with wildcard under macOS (fixes #2674)

(cherry picked from commit 3a6893dc51)
This commit is contained in:
Alexander Koblov 2026-01-05 13:57:30 +03:00
commit 76111e43d1
3 changed files with 10 additions and 2 deletions

View file

@ -57,6 +57,8 @@ const
ERROR_NOT_SAME_DEVICE = Windows.ERROR_NOT_SAME_DEVICE;
{$ENDIF}
FileNameNormalized = {$IFDEF DARWIN}True{$ELSE}False{$ENDIF};
type
TFileMapRec = record
FileHandle : System.THandle;

View file

@ -369,7 +369,7 @@ end;
constructor TStringHashListUtf8.Create(CaseSensitivity: boolean);
begin
fNormalize:= True;
fNormalize:= FileNameNormalized;
fCaseSensitive:= CaseSensitivity;
inherited Create;
end;

View file

@ -47,6 +47,7 @@ type
FTemplate: String;
FOriginal: String;
FMask: TMaskString;
FNormalize: Boolean;
FUsePinyin: Boolean;
FCaseSensitive: Boolean;
fIgnoreAccents: Boolean;
@ -97,7 +98,7 @@ uses
LazUTF8,
//DC
DCConvertEncoding, DCStrUtils, uPinyin, uAccentsUtils;
DCConvertEncoding, DCOSUtils, DCStrUtils, uPinyin, uAccentsUtils;
{ MatchesMask }
function MatchesMask(const FileName, Mask: String; const AOptions: TMaskOptions): Boolean;
@ -143,6 +144,7 @@ constructor TMask.Create(const AValue: string; const AOptions: TMaskOptions);
begin
FOriginal:= AValue;
FTemplate:= AValue;
FNormalize:= FileNameNormalized;
FUsePinyin:= moPinyin in AOptions;
FCaseSensitive := moCaseSensitive in AOptions;
fIgnoreAccents := moIgnoreAccents in AOptions;
@ -172,6 +174,7 @@ begin
if FIgnoreAccents then FTemplate := NormalizeAccentedChar(FTemplate);
// Let's set the mask early in lowercase if match attempt has to be case insensitive.
if not FCaseSensitive then FTemplate := UTF8LowerCase(FTemplate);
if FNormalize then FTemplate := NormalizeFileName(FTemplate);
// Treat mask differently for special cases:
// 1. foo*.* -> foo*
@ -282,6 +285,9 @@ begin
if not FCaseSensitive then
sFilename := UTF8LowerCase(sFilename);
if FNormalize then
sFilename := NormalizeFileName(sFilename);
if not fWindowsInterpretation then
Result := RegularMatches(sFileName)
else