FindAllFiles

From Free Pascal wiki
Revision as of 19:37, 16 February 2013 by BigChimp (talk | contribs) (Link to RTL version)

Template:Translate

Unit: Lazarus fileutil (UTF-8 replacements for FPC RTL code and additional file/directory handling)

See also:

function FindAllFiles(const SearchPath: String; SearchMask: String = '';
  SearchSubDirs: Boolean = True): TStringList;

findallfiles looks for files matching the searchmask in the SearchPath directory and if specified its children and returns a stringlist with the resulting filenames.

The mask can be a file name or...todo finish: can wildcards * and ? be used here?

Example:

uses 
...
fileutil
...
var
  SVNFiles: TStringList;
begin
  //No need to create the stringlist; the function does that for you
  SVNFiles := FindAllFiles(FSVNDirectory, 'svn' + LazUtils.GetExeExt, true); //find e.g. all svn.exe
  try
    if SVNFiles.Count > 0 then
    begin
      // Just get first result.
      showmessage('Found an svn executable: '+SVNFiles.Strings[0]);
    end;
  finally
    SVNFiles.Free;
  end;