Safe60
19th April 2011 15:55 UTC
confused by IfFileExists
Hi all.
I'm having a strange behaviour using IfFfilextist instruction. May be I'm using a wrong syntax, but anyway here is the code :
IfFileExists P:\spedizi\postallverG\*.MDD 0 +2
File p:\spedizi\postallverG\*.MDD
SetOutPath "$INSTDIR\..\Post"
The logic would be to check if some file with .mdd extension does exists in a specific directory located on a network disk. If at least one file exists, it should add all of them to the installation file. If not, it should skip the File statement and proceed with the SetOutputPath command.
Strangely, in any case, the program flow execute the File statement that fails making the compilation process to abort.
In the documentation the IiFfileExist command is documented this way :
file_to_check_for jump_if_present [jump_otherwise]
and the sample code of the statement is
IfFileExists $WINDIR\notepad.exe 0 +2
MessageBox MB_OK "notepad is installed"
I'm almost sure that I'm missing something but I can't guess what. May that the wildcards are not allowed ? Or the problem is in the remote path of the file to be checked ?
Thanks for your opinions.
Sandro
Highcoder
19th April 2011 17:01 UTC
...
The command explains itself. The name is IfFileExist and not IfExtensionExistInThisFolder. :D
You can only specify ONE FILE then it looks for THIS FILE. The command can´t search for fileextensions in specified folder...
You have to code it your own. But it shouldn´t be so tricky. ;)
Afrow UK
19th April 2011 19:22 UTC
Not to mention IfFileExists is a run-time instruction. You can't use to to check if a file exists on the build machine.
Stu
MSG
19th April 2011 21:08 UTC
Originally posted by Highcoder
You can only specify ONE FILE then it looks for THIS FILE. The command can´t search for fileextensions in specified folder...
IfFileExists accepts wildcards without any problems.
As Afrow said, IfFileExists is a runtime command, not compiletime. There are compiletime commands like !system that allow you to do some funky stuff like conditional file compilation. Or you can use a bat file to make a file list and !include that in your script. Or maybe execute a vbscript during compilation (forum search for this).
Afrow UK
19th April 2011 22:33 UTC
You can of course use wildcards with IfFileExists. As for File, you can use /nonfatal if you don't care whether the file should be included or not.
Please mind the language MSG.
Stu
MSG
20th April 2011 05:54 UTC
My bad, won't happen again. Thanks for the correction.
Highcoder
20th April 2011 06:57 UTC
...
Oh, really? Sorry. Learning never stops.
And never mind MSG. What i wrote was really utter b..... :)
I totally overlooked that he used it for compiletime...
Cheers
Safe60
20th April 2011 09:15 UTC
Many thanks for your opinions guys. I'm just a NSIS beginner and I need to further explore the language and the environment.
Sandro