!ifexist Macro: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (→Example: Removed comment end token from example as it broke the example.) |
m (Reverted edits by 178.32.211.140 to last version by Kichik) |
(3 intermediate revisions by 3 users not shown) | |
(No difference)
|
Latest revision as of 17:22, 15 August 2012
Author: Zinthose (talk, contrib) |
About
Macro to check for existence of file at compile time.
Example
${!IfNExist} "${__FILE__}" !error "File is Missing! How is that possible!" !else !echo "File Exists!" InitPluginsDir SetOutPath $PLUGINSDIR\SourceCode file "${__FILE__}" !endif ${!IfExist} "Config\Special.ini" !warning "Using Config data from external file." ## TODO Inport Config Data !else !warning "Using Config data from source file." ## TODO Add Config Data !endif
Macro
/* ${!IfExist} ---------------------------------------------------------------------- ${!IfExist} "C:\SomeFile.txt" !Error "File Exists!" !else !Error "File is Missing!" !endif */ !define !IfExist `!insertmacro _!IfExist ""` /* ${!IfNExist} ---------------------------------------------------------------------- ${!IfNExist} "C:\SomeFile.txt" !Error "File is Missing!" !else !Error "File Exists!" !endif */ !define !IfNExist `!insertmacro _!IfExist "n"` !macro _!IfExist _OP _FilePath !ifdef !IfExistIsTrue !undef !IfExistIsTrue !endif !tempfile "!IfExistTmp" !system `IF EXIST "${_FilePath}" Echo !define "!IfExistIsTrue" > "${!IfExistTmp}"` !include /NONFATAL "${!IfExistTmp}" !delfile /NONFATAL "${!IfExistTmp}" !undef !IfExistTmp !if${_OP}def !IfExistIsTrue !macroend