Old 11th November 2005, 19:06   #1
kingroach
Junior Member
 
Join Date: Nov 2005
Posts: 1
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:

Quote:
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?
kingroach is offline   Reply With Quote
Old 11th November 2005, 19:10   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Use the LogicLib:
code:
!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}


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 11th November 2005, 22:11   #3
bhaelochon
Junior Member
 
Join Date: Nov 2005
Location: Kansas City, MO, USA
Posts: 35
Send a message via ICQ to bhaelochon Send a message via AIM to bhaelochon Send a message via Yahoo to bhaelochon
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:
code:
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.

"Never hold your farts in. They travel up your spine and into your brain, and that's where you get shitty ideas from." - Unknown
bhaelochon is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump