rtl/amiga: added some basic infrastructure to MatchFirst to improve pattern matching in the future

This commit is contained in:
Karoly Balogh 2021-12-27 13:07:09 +01:00
parent 98dd448ce8
commit 3608be8f13

View File

@ -228,8 +228,16 @@ begin
NextDosEntry:=dlist;
end;
// Very first dirty version of MatchFirst/Next/End)
//TODO: pattern detection, for now only simple "*" or "#?" or full name (without patterns) is supported
{ helper function used by MatchFirst, all input is expected to be lowercase }
function NameMatchesPattern(pattern: AnsiString; filename: AnsiString): boolean;
begin
NameMatchesPattern:=(pattern = '*') or (pattern = '#?') or (pattern = filename);
if not NameMatchesPattern then
begin
// TODO: pattern detection
end;
end;
function MatchFirst(pat : PChar;
anchor: PAnchorPath): LongInt; public name '_fpc_amiga_matchfirst';
var
@ -310,7 +318,7 @@ begin
if Res = 0 then
break;
// include some nifty pattern compare here? later maybe!
if (FileN = '*') or (FileN = '#?') or (FileN = lowercase(AnsiString(ib.fib_FileName))) then
if NameMatchesPattern(FileN, lowercase(AnsiString(fib^.fib_FileName))) then
begin
// Match found
// new chain