Ihr habt Recht, ich hatte es schon wieder vertauscht
Hier also jetzt hoffentlich wieder richtig.
Delphi-Quellcode:
procedure FindAllFiles(FileList: TStrings; RootFolder: string; Mask: string = '*'; Recurse: Boolean = True; AddFolderNames: Boolean = False; IgnoreMaskAtFolderNames: Boolean = True);
procedure LFindAllFiles(AParentFolder: string; AMasks: TStrings);
function LIsInMasks(AFilename: String): Boolean;
var LCount: Integer;
begin
result := False;
for LCount := 0 to AMasks.Count - 1 do
begin
if Like(AFilename, AMasks.Strings[LCount]) then
begin
result := True;
break;
end;
end;
end;
var LSearchRec : TSearchRec;
begin
if FindFirst(AParentFolder + '*', faAnyFile, LSearchRec) = 0 then
begin
repeat
if (LSearchRec.Name <> '.') and (LSearchRec.Name <> '..') then
begin
if LSearchRec.Attr and faDirectory = faDirectory then
begin
if AddFolderNames and
(IgnoreMaskAtFolderNames or LIsInMasks(AnsiLowerCase(LSearchRec.Name))) then
FileList.AddObject(AParentFolder + LSearchRec.Name, TObject(True));
if Recurse then
LFindAllFiles(AParentFolder + LSearchRec.Name + '\', AMasks);
end
else if LIsInMasks(AnsiLowerCase(LSearchRec.Name)) then
FileList.AddObject(AParentFolder + LSearchRec.Name, TObject(False));
end;
until FindNext(LSearchRec) <> 0;
FindClose(LSearchRec);
end;
end;
var LMasks: TStringList;
begin
LMasks := TStringList.Create;
LMasks.Sorted := True;
LMasks.Duplicates := dupIgnore;
LMasks.Delimiter := '|';
LMasks.DelimitedText := AnsiLowerCase(Mask);
LFindAllFiles(IncludeTrailingPathDelimiter(RootFolder), LMasks);
LMasks.Free;
end;