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