Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Change Directory if it exists (http://forums.winamp.com/showthread.php?t=206617)

stonkers 1st February 2005 22:01

Change Directory if it exists
 
I'm having problems with a !cd that needs to happen "IF" a certain file exists (and thus the directory exists also). Here's my code:

-------------------------------------------------
IfFileExists "$INSTDIR\folder\file" +1 skip1
!cd "$INSTDIR\folder"

skip1:
;stuff...
-------------------------------------------------

I'm getting a compiler error because the directory doesn't exist. Is there a way to do this?

Thanks,
Eric

Joel 2nd February 2005 03:26

try IfFileExists with a folder... I think they use the same API for files and folders:
code:

Name boo
Caption boo
OutFile boo.exe
XPSTyle on
ShowInstDetails show

Section
IfFileExists $WINDIR 0 +3
StrCpy $0 "Folders exists"
Goto Exit
StrCpy $0 "OMG! You don't have windir :S"
Exit:
DetailPrint $0
SectionEnd


Comm@nder21 2nd February 2005 13:59

IfFileExists "$INSTDIR\folder\file" +1 skip1
!cd "$INSTDIR\folder"

you mixed some things up ...

"!cd" is a compiletime command
"$INSTDIR" is a runtime variable
"IfFileExists" is a runtime command

stonkers 2nd February 2005 18:40

I don't get it Comm@nder21, you put the same code as me there. It won't compile "because" !cd is a compiletime command. Is there a way to do what I'm trying to do (i.e. a way to change directories at runtime)?

Thanks,
Eric

Afrow UK 2nd February 2005 19:56

SetOutPath...

-Stu

Comm@nder21 2nd February 2005 20:05

i just copied your code and explained it to you.
i never posted a fix :)

now, here is one, if you DO WANT it to perform at RUNTIME:
code:
IfFileExists "$INSTDIR\folder\*.*" 0 +2 ; will jump 'over' the setoutpath command
SetOutPath "$INSTDIR\folder" ; will set the runtime var $OUTDIR to $INSTDIR\folder, all recursive file commands use this path as root. also do execute and shortcut commands (as working dir)


stonkers 2nd February 2005 21:23

Thanks Comm@nder21 and Afrow UK! I've seen that command but knew not what it was doing. Live long and prosper!


All times are GMT. The time now is 05:18.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.