Inno Setup Preprocessor: FindFirst

Prototype

int FindFirst(str Pattern, int Attrs)

Description

Searches for the first file matching the file name mask specified by the first parameter and the attributes specified by the second parameter. If a file is found, the result is a find handle to be used in subsequent calls to the FindGetFileName, FindNext, and FindClose functions, otherwise the return value is 0.

The first parameter is the directory and file name mask, including wildcard characters. For example, '.\*.*' specifies all files in the current directory.

The second parameter specifies the special files to include in addition to all normal files. Choose from these file attribute constants defined in ISPPBuiltins.iss when specifying this parameter:

faReadOnly Read-only files
faHidden Hidden files
faSysFile System files
faVolumeID Volume ID files
faDirectory Directory files
faArchive Archive files
faSymLink Symbolic links
faAnyFile Any file

Attributes can be combined by OR-ing their constants or values. For example, to search for read-only and hidden files in addition to normal files, pass faReadOnly | faHidden as the parameter.

Example

[Files]
#define FindHandle
#define FindResult
#define Mask "*.pas"

#sub ProcessFoundFile
  #define FileName FindGetFileName(FindHandle)
  #if Copy(FileName, 1, 4) == "ispp"
    Source: {#FileName}; DestDir: {app}\ispp
  #else
    Source: {#FileName}; DestDir: {app}
  #endif
#endsub

#for {FindHandle = FindResult = FindFirst(Mask, 0); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#if FindHandle
  #call FindClose(FindHandle)
#endif

See also

define, sub, if