Skip to content
⌘ NSIS Forum Archive

IfFileExists

5 posts

Gluck#

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:



Could someone make the spelling of this syntax? Please.
Anders#
\*.* means it is checking for a directory and +4 is a relative jump but you should be using labels in your code.
Gluck#
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.
Anders#
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.
Gluck#
"After it has been created you can verify that it is a folder and not a file"...

And how can I verify it?