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

SearchFileInPath

Searches for a file name in a given path using the specified base path and options.

Declaration

Source position: fileutil.pas line 90

function SearchFileInPath(

  const Filename: string;

  const BasePath: string;

  SearchPath: string;

  const Delimiter: string;

  Flags: TSearchFileInPathFlags

):string; overload;

Arguments

Filename

  

The name of the file to locate in the routine.

BasePath

  

Path used to resolve relative path references in a search path.

SearchPath

  

List of search paths examined in the routine.

Delimiter

  

Delimiter used to separate search paths.

Flags

  

Controls the file matching logic and behavior used in the routine.

Function result

Fully qualified file name for the file, or an empty string if the file was not found.

Description

SearchFileInPath is a String function used to get the fully-qualified name for the specified FileName in the specified search paths. When FileName contains an absolute path, and the file exists in the file system, no other directories are checked in the routine.

SearchPath contains the delimited list of search paths examined in the routine. Search paths are separated using the value in Delimiter.

BasePath contains the path used to resolve relative path references in SearchPath. By default, BasePath is also searched unless sffDontSearchInBasePath is included in the Flags parameter.

Flags contains values from the TSearchFileInPathFlag enumeration used to control the file matching logic used in the routine. For example:

sffDontSearchInBasePath
Prevents searching in the directory represented by BasePath.
sffFile
Excludes a directory entry that matches the file name.
sffExecutable
Exclude any file or directory name that is not an executable.

By default, the current directory is searched first. Each of the paths in SearchPaths are also searched until a file with the specified FileName is found.

The return value contains the fully-qualified path to the file including the file name and extension (when used). The first file that matches the supplied criteria is used in the return value. It may contain an empty string when a file with the given file name was not located.


Version 3.2 Generated 2024-02-25 Home