!ifexist Macro: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Initial) |
m (→Example: Removed comment end token from example as it broke the example.) |
||
Line 19: | Line 19: | ||
!warning "Using Config data from source file." | !warning "Using Config data from source file." | ||
## TODO Add Config Data | ## TODO Add Config Data | ||
!endif | !endif</highlight-nsis> | ||
== Macro == | == Macro == |
Revision as of 14:24, 28 September 2011
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