-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetFileList.pas
More file actions
37 lines (37 loc) · 925 Bytes
/
GetFileList.pas
File metadata and controls
37 lines (37 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function GetFileList(FDirectory, Filter: TFileName; ShowFolder:Boolean): TStringList;
//
// Cria um stringList com todos os arquivos de um diretório
// Aceita mascaras
//
var
ARec: TSearchRec;
Res: Integer;
begin
if FDirectory[Length(FDirectory)] <> '\'
then
begin
FDirectory := FDirectory + '\';
end;
Result := TStringList.Create;
try
Res := FindFirst(FDirectory + Filter, faAnyFile or faArchive, ARec);
while Res = 0 do
begin
if ((ARec.Attr and faArchive) = faAnyFile) or ((ARec.Attr and faArchive) = faArchive) then
begin
if ShowFolder then
begin
Result.Add(FDirectory + ARec.Name);
end
else
begin
Result.Add(ARec.Name);
end
end;
Res := FindNext(ARec);
end;
FindClose(ARec);
except
Result.Free;
end;
end;