Archive: Compare file sizes


Compare file sizes
Hello. I want to add a section in my installer that would allow me to compare some file sizes to ensure the installer did its job, and newer files were copied into place. I'm trying to guard against a user not having rights, or having a file locked, and not updated.

I did some searching and I found a thread from about 2 years ago. It said I could use the following script to compare file sizes. I don't really understand how to incorporate or use this code within my own. Could someone help me out. Thanks.


outfile FileSizeNew.exe
name FileSizeNew

; FileSizeNew
;
; Script to find the size of a file.
; Much more efficient than the
; ExtensionDLL FileSize :-)
;
; by Hendri Adriaens
; HendriAdriaens@hotmail.com

section
Push "$EXEDIR\FileSizeNew.nsi"
Call FileSizeNew
Pop $0
MessageBox MB_OK "File size: $0 bytes."
sectionend

function FileSizeNew
Exch $0
Push $1
FileOpen $1 $0 "r"
FileSeek $1 0 END $0
FileClose $1
Pop $1
Exch $0
functionend


1) To compare numbers you can use IntCmp command. To compare really big numbers (64-bits) you can use System plugin. To convert these numbers to kb, you can use IntOp $var $var * 1024.

OR

2) To make calculations with this number in an advanced way, is prefferable to use Math plugin.

If you would like me to make an example for you, choose one of the options above.


deguix, thanks for the reply. Boy, I'm still a bit confused. Basically, after my update, there will be a file here called: "$INSTDIR\GPLoans\GPAdmin.exe". I know its file size should be 5,066,752 bytes. I would like to verify this. Thanks.

Jnuw


You would be better of comparing files using MD5 values:

http://nsis.sourceforge.net/archive/...b.php?page=488

-Stu


Yeah, I should use that dll too...