Reference/FindFirst: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Fixed inconsistent reference from FileClose to FindClose)
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:
  user_var(handle output) user_var(filename output) filespec
  user_var(handle output) user_var(filename output) filespec


Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with [[Reference/FindNext|FindNext]] and [[Reference/FileClose|FileClose]]. Note that the filename output is without path.
Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with [[Reference/FindNext|FindNext]] and [[Reference/FindClose|FindClose]]. Note that the filename output is without path.


<highlight-nsis>FindFirst $0 $1 $INSTDIR\*.txt
<highlight-nsis>FindFirst $0 $1 $INSTDIR\*.txt
Line 13: Line 13:
done:
done:
FindClose $0</highlight-nsis>
FindClose $0</highlight-nsis>
''Command introduced with NSIS v1.60''

Latest revision as of 00:12, 1 September 2016

FindFirst

user_var(handle output) user_var(filename output) filespec

Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with FindNext and FindClose. Note that the filename output is without path.

FindFirst $0 $1 $INSTDIR\*.txt
loop:
  StrCmp $1 "" done
  DetailPrint $1
  FindNext $0 $1
  Goto loop
done:
FindClose $0

Command introduced with NSIS v1.60