sgregerson
18th November 2008 07:10 UTC
Version checking code snippets? Anyone?
Anyone have version checking code to allow the NSIS installer to copy files on top of older files while preventing newer files from be overwritten by performing a version check of the file being copied such as file date, size and time stamp.
Thanks
Steve
Red Wine
18th November 2008 08:19 UTC
SetOverwrite doesn't do the job?
http://nsis.sourceforge.net/Docs/Chapter4.html#4.8.2.8
Comperio
18th November 2008 16:07 UTC
RedWine, that option only works with the file command. If you use CopyFiles, then you're out of luck. (There is an open request item dealing with this.)
My best suggestion would be to use XCOPY with nsExec to do the work. (From a Windows command, type 'xcopy /?' to get a list of all the command options.)
Otherwise, you'll have to "invent" your own code within NSIS to handle it.
{_trueparuex^}
20th November 2008 18:32 UTC
WordFunc.nsh has an ${VersionCompare} function and with GetDLLVersion & GetDLLVersionLocal (it works with any files that contains version information) you can get the versions from the files.
Example:
!include "WordFunc.nsh"
...
GetDLLVersionLocal "C:\myfile.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
GetDLLVersion "$INSTDIR\myfile.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $1 "$R2.$R3.$R4.$R5"
${VersionCompare} $0 $1 $R0
IntCmp $R0 1 skipfile skipfile 0
File "C:\myfile.exe"
skipfile:
It's quite much code for just one file, but it should work. I haven't tested it though.
PaR
sgregerson
20th November 2008 19:09 UTC
Thank you all! I will pass this helpful info to my programmer.
Again, Thanks!:D