[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'Unix' (#rtl)

FSearch

Search for file in search path.

Declaration

Source position: unix.pp line 133

function FSearch(

  const path: AnsiString;

  dirlist: Ansistring;

  CurrentDirStrategy: TFSearchOption

):AnsiString;

function FSearch(

  const path: AnsiString;

  dirlist: AnsiString

):AnsiString;

Description

FSearch searches in DirList, a colon separated list of directories, for a file named Path. It then returns a path to the found file.

The CurrentDirStrategy determines how the current directory is treated when searching:

NoCurrentDirectory
Do not search the current directory unless it is specified in the search path.
CurrentDirectoryFirst
Search the current directory first, before all directories in the search path.
CurrentDirectoryLast
Search the current directory last, after all directories in the search path

It is mainly provided to mimic DOS search path behaviour. Default behaviour is to search the current directory first.

Errors

An empty string if no such file was found.

See also

#rtl.unixutil.FNMatch

  

Check whether filename matches wildcard specification

Example

Program Example46;

{ Program to demonstrate the FSearch function. }

Uses BaseUnix, Unix, Strings;

begin
  Writeln ('ls is in : ',FSearch ('ls',strpas(fpGetenv('PATH'))));
end.

Documentation generated on: Nov 16 2015