Archive: IFfileExist trouble


IFfileExist trouble
I need to make the install directory exactly 500MB. So I use some filler. blank .img files in installer. After installing all the fillers, depending on what components are installed, I need to delet few fillers that were installed.I am using this script:

IfFileExists "$INSTDIR\C\shadowc\id1.bin" 0 idac1
Delete "$INSTDIR\C\shadowc\filler2.img"
Delete "$INSTDIR\C\shadowc\filler1.img"
idac1:
Delete "$INSTDIR\C\shadowc\filler3.img"
Delete "$INSTDIR\C\shadowc\filler1.img"
it works fine when there is no "$INSTDIR\C\shadowc\id1.bin" ( deletes filler3 and filler1) but when there is a id1.bin file, it first deletes filler2 and filler1 and then deletes filler3. Am I using the IfFileExists command right?

Use the LogicLib:

!include LogicLib.nsh
# ...
${If} ${FileExists} "$INSTDIR\C\shadowc\id1.bin"
Delete "$INSTDIR\C\shadowc\filler2.img"
Delete "$INSTDIR\C\shadowc\filler1.img"
${Else}
Delete "$INSTDIR\C\shadowc\filler3.img"
Delete "$INSTDIR\C\shadowc\filler1.img"
${EndIf}

I agree with kichik--LogicLib structures logic in a familiar programming-style manner. Regardless: In answer to your actual question, yes, you're using IfFileExists correctly. The reason it's deleting filler3 is you're basically telling it to. Try this:

IfFileExists "$INSTDIR\C\shadowc\id1.bin" 0 idac1
Delete "$INSTDIR\C\shadowc\filler2.img"
Delete "$INSTDIR\C\shadowc\filler1.img"
Goto skip_idac1 ;skip 'idac1' group of files

idac1:
Delete "$INSTDIR\C\shadowc\filler3.img"
Delete "$INSTDIR\C\shadowc\filler1.img"

skip_idac1:
;continue with other logic here

Hope that helps. :)