Archive: do NOT overwrite APEs


11th June 2003 11:02 UTC

nsis: avoid overwriting
i recently figured somebody overwrote my colormap.ape with and older version. please add a check to your script.

example with multiplier ape:
Section "Multiplier"
SetOutPath "$INSTDIR\Plugins\avs\"
SectionIn 1
IfFileExists "$INSTDIR\Plugins\avs\multiplier.ape" ExistMessage CopyAPE
ExistMessage:
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Setup detected the Multiplier APE in your Plugins directory.$\n$\nOverwrite anyway?" IDNO End
CopyAPE:
File "multiplier.ape"
End:
SectionEnd


if you dont want the ExistMessage, just change the GOTO of IfFileExists to End. additionally you check for the version of the installed ape. read this for details.


11th June 2003 11:08 UTC

just insert something like this to the script above to check for the version. i did this a while ago, i'm sure it'd be more clever to use StrCmp on "0" instead of "1.1".

..
IfFileExists "$INSTDIR\$1\colormap.ape" VersionCheck CopyAPE
VersionCheck:
GetDllVersion "$INSTDIR\$1\colormap.ape" $R4 $R9
IntOp $R7 $R4 / 0x00010000
IntOp $R8 $R4 & 0x0000FFFF
StrCpy $0 "$R7.$R8"
StrCmp $0 "1.1" ExistMessage
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Setup detected an old Color Map APE in your Plugins directory.$\n$\nDo you want to update?" IDNO End

..

you might want to change the variables ($0, $R4 etc.) to fit your script!

ps: i intentionally did not use the edit button :D


11th June 2003 11:18 UTC

ah, your a big dude now eh ? ... :D


11th June 2003 11:44 UTC

There is a reason why i put them on a separate section :weird: Do i really need to add this script also? It's friggin huge for one file...


11th June 2003 13:15 UTC

Yathosho: you can use GetDllVersionLocal (or whatever it's called) to check the version of colormap on *your* PC as well. So that way you never have to update your script if you use a newer APE.