findfiles
findfiles |
Purpose
Search for files according to file name patterns.
Synopsis
procedure findfiles(opt:integer,lsf:list of text, dir:string|text,filters:string|text)
procedure findfiles(opt:integer,lsf:list of text,filters:string|text)
procedure findfiles(lsf:list of text,filters:string|text)
procedure findfiles(lsf:list of text)
Arguments
opt
|
Options (several options can be combined):
|
||||||||||
lsf
|
Resulting list of file names
|
||||||||||
dir
|
Base directory for the search (default: current directory)
|
||||||||||
filters
|
File name filters (default: all files reported)
|
Example
The following prints the list of files with extension
.mos and
.bim of the current directory:
findfiles(lsf,"*.mos|*.bim") writeln(lsf)
Further information
1. The
filters argument consists in a list of patterns separated by the symbol
";": for each of these patterns the function executes a search from the specified
dir directory. A pattern is composed of a path (using the usual operating system conventions) which last component may include wildcard characters
"*" (any text of any length),
"?" (any single character) and
"|" (logical "or"). For instance
"bin/*.exe;models/*.mos|*.dat" will select all files with extension
".exe" in the
"bin" directory as well as files with extension
".mos" and
".dat" in the
"models" directory.
2. File name matching is achieved using function
pathmatch and differences may be observed depending on the operating system (
e.g. file names are case sensitive under Posix systems but not under Windows).
3. Unless option
SYS_NOSORT is used, the resulting list is sorted and duplicate entries are removed. Note also that the provided list
lsf is not reset: the result of the search is appended to this list.
Related topics
Module