Inno Setup Preprocessor: FindFirst

Prototype

int FindFirst(str, int)

Description

Searches the directory specified by first parameter for the first file that matches the file name implied by first parameter and the attributes specified by second parameter. If the file is found, the result is a find handle, that should be used in subsequent calls to 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
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 LowerCase(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
  #expr FindClose(FindHandle)
#endif

See also

define, sub, if.