Difference between revisions of "FindAllFiles"

From Free Pascal wiki
(Link to RTL version)
Line 2: Line 2:
  
 
Unit: Lazarus '''fileutil''' (UTF-8 replacements for FPC RTL code and additional file/directory handling)
 
Unit: Lazarus '''fileutil''' (UTF-8 replacements for FPC RTL code and additional file/directory handling)
 +
 +
See also:
 +
* http://lazarus-ccr.sourceforge.net/docs/lcl/fileutil/findallfiles.html
 +
* http://lazarus-ccr.sourceforge.net/docs/lcl/fileutil/tfilesearcher.html
  
 
<syntaxhighlight>
 
<syntaxhighlight>

Revision as of 19:37, 16 February 2013

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;