Archive: error during CreateDir


error during CreateDir
The following code triggers an alarm unless the folder already exists:

ClearErrors
${CreateDirectory} "c:\folder"
IfErrors 0 +2
MessageBox MB_OK "Failed to create folder: $0"

I have exactly the same problem with CopyFiles


Are you using this.
Not enough information really.

-Stu


I was having a similar problem recently. I found out in my situation that it was becuase I was using some relative jumps in my macros that actually caused the code to jump to my error routine when there wasn't really an error at all.

My solution was to use labels instead of relative jumps. That might work for you too with the line that reads "IfErrors 0 +2"


I still have the same problem with label jump...

${RecFindOpen} "$EXEDIR\Media" $R0 $R1
ClearErrors
CreateDirectory "$TARGET$R0"
IfErrors exitWithFolderErrors
${RecFindFirst}
ClearErrors
CopyFiles "$EXEDIR\Media$R0\$R1" "$TARGET$R0\$R1"
IfErrors exitWithFileErrors
${RecFindNext}
${RecFindClose}

exitWithFolderErrors:
MessageBox MB_OK "Failed to create folder: $TOPKAPI_FOLDER$R0 ($0)"
Quit
exitWithFileErrors:
MessageBox MB_OK "Failed to copy file: $TOPKAPI_FOLDER$R0\$R1 ($0)"
Quit

The folder is created, but I have an error...


Are you using the latest version of NSIS? I think I recall a bug fixed in some version that caused CreateDirectory to raise the error flag with no good reason.