mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 20:58:16 +02:00
TFileSearcher: Implement FileAttribute and DirectoryAttribute properties to let user control
what files and directories are searched. Fixes issue #0024369. git-svn-id: trunk@41031 -
This commit is contained in:
parent
19a204485e
commit
f84bed8662
@ -1425,6 +1425,8 @@ constructor TFileSearcher.Create;
|
||||
begin
|
||||
FMaskSeparator := ';';
|
||||
FFollowSymLink := True;
|
||||
FFileAttribute := faAnyFile;
|
||||
FDirectoryAttribute := faDirectory;
|
||||
FSearching := False;
|
||||
end;
|
||||
|
||||
@ -1440,7 +1442,7 @@ var
|
||||
begin
|
||||
P := APath + AllDirectoryEntriesMask;
|
||||
|
||||
if FindFirstUTF8(P, faAnyFile, PathInfo) = 0 then
|
||||
if FindFirstUTF8(P, FileAttribute, PathInfo) = 0 then
|
||||
try
|
||||
repeat
|
||||
// skip special files
|
||||
@ -1475,7 +1477,7 @@ var
|
||||
|
||||
if ASearchSubDirs or (ALevel > 0) then
|
||||
// search recursively in directories
|
||||
if FindFirstUTF8(P, faDirectory, PathInfo) = 0 then
|
||||
if FindFirstUTF8(P, DirectoryAttribute, PathInfo) = 0 then
|
||||
try
|
||||
repeat
|
||||
if (PathInfo.Name = '.') or (PathInfo.Name = '..') or
|
||||
|
@ -145,12 +145,15 @@ type
|
||||
|
||||
{ TFileSearcher }
|
||||
|
||||
|
||||
TFileSearcher = class(TFileIterator)
|
||||
private
|
||||
FMaskSeparator: char;
|
||||
FFollowSymLink: Boolean;
|
||||
FOnFileFound: TFileFoundEvent;
|
||||
FOnDirectoryFound: TDirectoryFoundEvent;
|
||||
FFileAttribute: Word;
|
||||
FDirectoryAttribute: Word;
|
||||
procedure RaiseSearchingError;
|
||||
protected
|
||||
procedure DoDirectoryEnter; virtual;
|
||||
@ -163,6 +166,8 @@ type
|
||||
public
|
||||
property MaskSeparator: char read FMaskSeparator write FMaskSeparator;
|
||||
property FollowSymLink: Boolean read FFollowSymLink write FFollowSymLink;
|
||||
property FileAttribute: Word read FFileAttribute write FFileAttribute default faAnyfile;
|
||||
property DirectoryAttribute: Word read FDirectoryAttribute write FDirectoryAttribute default faDirectory;
|
||||
property OnDirectoryFound: TDirectoryFoundEvent read FOnDirectoryFound write FOnDirectoryFound;
|
||||
property OnFileFound: TFileFoundEvent read FOnFileFound write FOnFileFound;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user