- NSIS Discussion
- error with zipdll
Archive: error with zipdll
rod78
4th February 2006 17:46 UTC
error with zipdll
I'm a newbie starting to use zipdll plugin.
I can't understand what's wrong with this script.
The setup terminates but with only example1.nsi in the destination directory, the content of the zipfile is not extracted. Details windows reports a strange error:
Output folder: C:\666666
Extract: example1.nsi... 100%
Extracting contents of test.zip to C:\666666
Error:
Completed
I include the source, please help.
!include "zipdll.nsh"
; The name of the installer
Name "Name"
; The file to write
OutFile "setup.exe"
; The default installation directory
InstallDir $PROGRAMFILES\example
;Page license
Page directory
Page instfiles
Function .onInit
MessageBox MB_YESNO "This will install my program. Do you wish to continue?" IDYES gogogo
Abort
gogogo:
IfFileExists "test.zip" +9 0
MessageBox MB_RETRYCANCEL "zipfile not found" IDRETRY true IDCANCEL false
true:
Goto gogogo
false:
MessageBox MB_ICONSTOP "Installation aborted."
Abort
FunctionEnd
; The stuff to install
Section "" ;No components page, name is not important
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File example1.nsi
!insertmacro ZIPDLL_EXTRACT "test.zip" "$OUTDIR" "<ALL>"
SectionEnd ; end the section
Thanks for your support :)
kichik
4th February 2006 17:53 UTC
This code is wrong:
IfFileExists "test.zip" +9 0
You're jumping over the function's end. Labels are not instructions. That should probably be +5, but you should use a label anyway, it's simpler. You can also use the
LogicLib, it's even simpler than that.
rod78
4th February 2006 18:02 UTC
kichik, thanks for your response but i tried to remove the entire .onInit function and the error is still the same. :(
Comperio
4th February 2006 18:03 UTC
This is one example where it may be better to avoid relative jumps.
If you use relative jumps, you'll have to remember to change them any time you add or remove lines of code.
But, if you do as kichik suggests, you can make your code a bit more forgiving.
Comperio
4th February 2006 18:09 UTC
It looks like you are checking for the zip file in $PROGRAMFILES\example, but then you let the user pick another directory for the installation. So, by the time you get to the section, you have switched to the $INSTDIR and are trying to unzip the file (which, of course, does not exist there.)
If you expect the zip file to exist in the target folder, then you need to do you check AFTER the user picks the directory.
rod78
4th February 2006 18:34 UTC
Thanks again for your help people but i think the main problem is not caused by wrong checking directory. Even this simple code doesn't work:
!include "zipdll.nsh"
OutFile "setup.exe"
InstallDir $PROGRAMFILES\example
Section
SetOutPath $INSTDIR
!insertmacro ZIPDLL_EXTRACT "test.zip" "$OUTDIR" "<ALL>"
SetOutPath $INSTDIR
File example1.nsi
SectionEnd
If i change "$OUTDIR" to a specified path (i.e "c:\test") it works as expected. But i need to extract a zipfile (located in the same dir of the installer) into the destination dir.
Comperio
4th February 2006 19:08 UTC
OK, I downloaded ziplib just so I could see what was going on.
I think I may have found the problem:
the insertmacro command (ZIPLIB_EXTRACT) is a compile-time command. $OUTDIR is a runtime variable. Therefore, $OUTDIR won't be defined when the insertmacro command is called, which is likely why your script is failing.
I found that if I changed the statement to call the plugin directly, it works perfectly:
ZipDLL::extractall "test.zip" "$OUTDIR"
The other alternative would be to wrap the extract commands into a function that you can call during runtime, but using the pluging directly is probably just as easy unless you need additional language support. (You may even want to talk to the author about any addtional change requests.)
rod78
4th February 2006 19:16 UTC
Thanks Comperio, it make sense.
But your code still output an error (see details) and the content of the zipfile is not extracted.
Can you confirm please ?
I'm using this code:
!include "zipdll.nsh"
OutFile "setup.exe"
InstallDir $PROGRAMFILES\example
Section
SetOutPath $INSTDIR
ZipDLL::extractall "test.zip" "$OUTDIR"
File example1.nsi
SectionEnd
rod78
4th February 2006 19:46 UTC
I resolved the problem.
I need to use "$EXEDIR\test.zip" to locate the zipfile correctly. Please forgive me for spamming the forum :)
Thanks for your help.
Comperio
4th February 2006 20:09 UTC
Open mouth, insert foot...
I found out that I had setup my testing wrong before. Turns out that $OUTDIR really DOES work in your example above.
(I forgot that I used a different ZIP file in my 2 tests, but I failed to change the name in my script. This is why I inorrectly assumed it was a compile-time/runtime problem.)
At least it good to know that someone was awake!
:tinfoil: