Old 13th May 2018, 08:55   #1
Gluck
Member
 
Join Date: Apr 2018
Posts: 80
IfFileExists

I've found this code:

!define PORTABLEDIR1 "$EXEDIR\Data\MyApp"
!define LOCALDIR1 "$APPDATA\MyApp"

RMDir "/r" "${LOCALDIR1}-BackupBy${APPNOSPACE}Portable"
Rename "${LOCALDIR1}" "${LOCALDIR1}-BackupBy${APPNOSPACE}Portable"

IfFileExists "${PORTABLEDIR1}\*.*" +4
IfFileExists "$EXEDIR\Data\${APP}\*.*" 0 +5

CreateDirectory "${PORTABLEDIR1}"
CopyFiles /SILENT "$EXEDIR\Data\${APP}\*.*" "${PORTABLEDIR1}"

CreateDirectory "${LOCALDIR1}"
CopyFiles /SILENT "${PORTABLEDIR1}\*.*" "${LOCALDIR1}"

All the code is clear except for the central lines: IfFileExists "$...

I've found this description:

http://nsis.sourceforge.net/Reference/IfFileExists

Could someone make the spelling of this syntax? Please.
Gluck is offline   Reply With Quote
Old 13th May 2018, 11:19   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
\*.* means it is checking for a directory and +4 is a relative jump but you should be using labels in your code.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th May 2018, 14:16   #3
Gluck
Member
 
Join Date: Apr 2018
Posts: 80
IfFileExists "${PORTABLEDIR1}\*.*" +4

But if I haven't a label, what paramenter I have to pass? What is 0 (in the second line)?

I want only verify if folder exists. If not, create it.
Gluck is offline   Reply With Quote
Old 13th May 2018, 18:31   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
0 is a zero jump, continues execution on the next line. The second label/offset is optional.

You don't have to check if a folder exists, you can just create it. After it has been created you can verify that it is a folder and not a file if you really care.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 14th May 2018, 07:49   #5
Gluck
Member
 
Join Date: Apr 2018
Posts: 80
"After it has been created you can verify that it is a folder and not a file"...

And how can I verify it?
Gluck 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