[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'FileUtil' (#lazutils)

TFileSearcher.Search

Searches for files or directories in the specified path(s) using the specified options.

Declaration

Source position: fileutil.pas line 148

public procedure TFileSearcher.Search(

  const ASearchPath: string;

  const ASearchMask: string = '';

  ASearchSubDirs: Boolean = True;

  CaseSensitive: Boolean = False

);

Arguments

ASearchPath

  

Base path for searching files.

ASearchMask

  

Mask used to determine file names that match in the search.

ASearchSubDirs

  

Indicates if subdirectories are searched recursively.

CaseSensitive

  

Indicates if file names are compared using case sensitivity.

Description

Search is a method used to search for files or directories matching a specified mask found in the specified search paths. ASearchPath contains the locations examined in the method, and can contain multiple path names separated by the value in PathSeparator. Each delimited path value in ASearchPath is resolved by calling the ResolveDots function, and processed in the method.

The value in the CaseSensitive argument is used to add or remove mask options for the search mask in ASearchMask. Set CaseSensitive to True before calling Search to perform file name comparisons with case sensitivity.

ASearchSubDirs includes subdirectories found in ASearchMask in the search process when set to True.

Set the value in FileAttribute to control the file attributes included in the search process. The default value (faAnyFile) allows all files to be considered.

Set the value in DirectoryAttribute to control whether directory names are included in the search process. The default value (faDirectory) includes directory names.

Set the value in FollowSymLink to indicate whether symbolic links in the file system are followed in the method.

When a matching file is found, the OnFileFound event is signalled. For directories, the OnDirectoryFound event is signalled. When a new directory is processed in the method, the OnDirectoryEnter events is signalled. Applications must assign a handler for the events to respond to the notifications. You can abort the search process by calling the Stop method in the handlers for these events.

Errors

Calls RaiseSearchingError to raise an exception if the Search method has already been called and has not completed.

See also

TFileSearcher.OnFileFound

  

Event handler signalled when a file matching the file mask is found in the Search method.

TFileSearcher.OnDirectoryFound

  

Event handler signalled when a new directory is found in the Search method.

TFileSearcher.OnDirectoryEnter

  

Event handler signalled when a new directory is processed in the Search method.

TFileSearcher.FileAttribute

  

File attribute needed for any file considered a match in the Search method.

TFileSearcher.DirectoryAttribute

  

File attribute needed for directories considered a match in the Search method.

TFileSearcher.FollowSymLink

  

Indicates if a search process directory paths that are symbolic links.

TFileSearcher.PathSeparator

  

Character used as a delimiter between directory paths.

TFileSearcher.MaskSeparator

  

Character used as a delimiter between file masks.

TFileIterator.Stop

  

Stops the search process.