Old 4th February 2006, 17:46   #1
rod78
Guest
 
Posts: n/a
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
  Reply With Quote
Old 4th February 2006, 17:53   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
This code is wrong:
code:
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 4th February 2006, 18:02   #3
rod78
Guest
 
Posts: n/a
kichik, thanks for your response but i tried to remove the entire .onInit function and the error is still the same.
  Reply With Quote
Old 4th February 2006, 18:03   #4
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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 is offline   Reply With Quote
Old 4th February 2006, 18:09   #5
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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.
Comperio is offline   Reply With Quote
Old 4th February 2006, 18:34   #6
rod78
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 4th February 2006, 19:08   #7
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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.)
Comperio is offline   Reply With Quote
Old 4th February 2006, 19:16   #8
rod78
Guest
 
Posts: n/a
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
  Reply With Quote
Old 4th February 2006, 19:46   #9
rod78
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 4th February 2006, 20:09   #10
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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!
Comperio is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump