Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Zip plugin


  • Please log in to reply
99 replies to this topic

#1 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 19 April 2007 - 09:09 PM

The moment you've all been waiting for [drum roll...] (yeah, right)
Zip Plugin for AutoIt V3.

It adds the following functions:
  • _ZipCreate($NewZipFile) Returns a handle to the zip.
  • _ZipAdd($hFile,$SourceFile,$FileNameInsideZip) Needs handle from _ZipCreate.
  • _ZipAddDir($hFile,$DirToAdd,$Recursive) Needs handle from _ZipCreate 1 use recursion 0 don't.
  • _ZipAddFolder($hFile,$FolderName) Creates an empty folder in the zip Needs handle from _ZipCreate.
  • _ZipFormatMessage($ErrorCode) Returns the message that corresponds with the $ErrorCode.
  • _ZipClose($hFile) Closes the Zip archive. Needs handle from _ZipCreate.
  • _ZipUnZip($ZipFile,$Dest) UnZips the archive to the specified folder.
  • _ZipUnZipItem($ZipFile,$FileNameInsideZip,$Dest) UnZips the specified file to dest.
  • _ZipGetList($ZipFile) Retrieves file info from zip.
  • _ZipGetCount($ZipFile) Retrieves then number of items in the zip.
  • _ZipGetItemInfo($ZipFile) Return a ptr to the file info a specific item.
  • _ZipAddFileToZip($ZipFile,$FileToAdd,$FileNameInsideZip) adds a file to an already existing zip.
  • _ZipDeleteFile($ZipFile,$FileNameInsideToDelete) Deletes a file inside the archive.
  • _ZipPluginAbout() Returns "About" message string.
Based on ZLib and Info-Zip code condensed by Lucian Wischik. See this CodeProject.

The UDF _ZipPlugin.au3 is needed to extract the file information data (name, size, etc...) for the items in the zip from the _ZipGetList() function return. This function returns a compound delimited string. Each entry is delimited by @LF, each param is delimited by a semicolon. It would be nice to be able to return an array from plugins.

The UDF contains a number of helper function.
  • _ZipItemInfo2Array($ZipFile,$iIndex) Retrieves file info from zip and return as 1 Dim array.
  • _ZipList2Array($ZipFile) Retrieves file info from zip for all items and returns a 2 Dim array
  • _ZipGetItemInfoFromPtr($ptrZipInfo) Converts struct from ptr [ provided by _ZipGetItemInfo() ] to 1 Dim array. (Internal use.)
* _ZipList2Array should be used instead of _ZipGetList() *

The original CodeProject source archive is included with the plugin archive as is an Au3 example script. There is also a script that can be compiled into an exe for a Code::Blocks tool to zip the current project. The CodeBlocks_Tools.jpg shows the settings. Adjust the location of the exe accordingly.

You can get the latest version here.
Here is a direct link to Au3_Zip_1.0.408a.zip

Enjoy,

eltorro

Edit: Added _ZipUnZipItem()
Edit: Change the name of the download
Edit: Removed _ZipGetList() -Plugin
Added _ZipGetCount() -Plugin
_ZipGetItemInfo() -Plugin
_ZipItemInfo2Array() -UDF
_ZipList2Array() -UDF
Edit: Added checks for file existence
Check if file is a zip.
Edit: Fixed unneeded zip check in _ZipAddDir.
Edit: Uploaded files to server. Replaced incorrect Au3 include file in zip package.
Edit: Fixed crash with bad or otherwise incorrect zip file.
Edit: Fixed extraction of 0 byte file.
Edit: Fixed failed check for source folder.
Edit: Replaced _ZipPlugin.pll.au3 with correct file.

Edited by eltorro, 17 June 2008 - 09:16 PM.








#2 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 19 April 2007 - 09:25 PM

So of all the files in the .zip (by the way, it seems your ocotillo.sytes.net upload may be corrupted?), we only need _ZipPlugin.au3? None of the other *.c or *.dll files are needed, or do we need to fully extract all the contents of the .zip file into the script directory and rely on external .dll (and other?) files?

I'll try this out in a bit - if it's pure AutoIt, this looks great! :-)
Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,713 posts

Posted 19 April 2007 - 09:28 PM

Looks really cool but there is missing _ZipUnZipFile() for unzip just one file - and not all files like your _ZipUnZip() does

_ZipUnZip($ZipFile,$Dest) UnZips the archive to the specified folder.



#4 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,298 posts

Posted 19 April 2007 - 09:34 PM

Pure AutoIt Zip functions would make a definite built in UDF.

#5 smashly

smashly

  • Active Members
  • PipPipPipPipPipPip
  • 1,636 posts

Posted 19 April 2007 - 10:48 PM

Nice work, Thank you eltorro.

Can I set the compression level of the zip I create?

Edit: Any plans to add
Example 3 - unzip from resource directly into memory
Example 4 - unzip chunk by chunk to a membuffer
Or is this already supported ?

Edited by smashly, 19 April 2007 - 11:10 PM.


#6 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,692 posts

Posted 20 April 2007 - 01:19 AM

I am glad to see more interest in plugins! They are still incomplete, so I hope this new interest in plugins will show Jon there is enough interest in that architecture to complete it.

Looks like a great plugin. I have saved it to look at it later.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)


#7 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 20 April 2007 - 02:06 AM

Nice work, Thank you eltorro.

Can I set the compression level of the zip I create?

Edit: Any plans to add
Example 3 - unzip from resource directly into memory
Example 4 - unzip chunk by chunk to a membuffer
Or is this already supported ?


The zip source supports it but it is not implemented in the plugin. There is also provisions to extract/compress to/from a membuffer that the plugin does not exploit.


I am glad to see more interest in plugins! They are still incomplete, so I hope this new interest in plugins will show Jon there is enough interest in that architecture to complete it.



It kind of a "catch 22" isn't it. Some are holding out for completion, Jon looking for interest in plugins.

I would be nice if it were possible to pass an array back in the same manner as the other variable types.


eltorro

#8 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,692 posts

Posted 20 April 2007 - 02:19 AM

It kind of a "catch 22" isn't it. Some are holding out for completion, Jon looking for interest in plugins.

I would be nice if it were possible to pass an array back in the same manner as the other variable types.
eltorro

That is what I am waiting on to complete my SQLite plugin. I am sure it would come in handy for other plugins as well.

I dont want to bother Jon as I know he has started his new job, and doing that can be quite taxing till you get in the swing of things, but it may help if you post in the plugins thread on the developer forum. Letting Jon know of your interest in the plugins side of AutoIt.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)


#9 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 20 April 2007 - 08:13 AM

That is what I am waiting on to complete my SQLite plugin. I am sure it would come in handy for other plugins as well.

I dont want to bother Jon as I know he has started his new job, and doing that can be quite taxing till you get in the swing of things, but it may help if you post in the plugins thread on the developer forum. Letting Jon know of your interest in the plugins side of AutoIt.

JS



Arrays are such an intergal part of code. It is almost a necessity. I may post in the developers forum as you suggested.

eltorro

#10 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 20 April 2007 - 11:09 PM

Nice work, Thank you eltorro.

Can I set the compression level of the zip I create?

Edit: Any plans to add
Example 3 - unzip from resource directly into memory
Example 4 - unzip chunk by chunk to a membuffer
Or is this already supported ?


I looked at the code last night and again this morning. I don't see where to change it. I made a couple of changes but the results weren't what I expected. So I left it alone.

eltorro

#11 Eru

Eru

    Wayfarer

  • Active Members
  • Pip
  • 57 posts

Posted 22 April 2007 - 01:01 AM

I haven't tried to install an autoit plugin yet, and this is making me feel really stupid. I downloaded the zip file and extracted it to my \include directory. I include the file as such:

#include<Au3Zip\bin\_ZipPlugin.au3>

It checks fine when I CTRL+F5 in SciTE, but when I run the script, it says that the _ZipCreate function isn't defined. What am I doing wrong?

Sorry if this is a moronic question. :shocked:

#12 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,692 posts

Posted 22 April 2007 - 01:05 AM

I haven't tried to install an autoit plugin yet, and this is making me feel really stupid. I downloaded the zip file and extracted it to my \include directory. I include the file as such:

#include<Au3Zip\bin\_ZipPlugin.au3>

It checks fine when I CTRL+F5 in SciTE, but when I run the script, it says that the _ZipCreate function isn't defined. What am I doing wrong?

Sorry if this is a moronic question. :shocked:

You are doing nothing wrong at all. Just continue, and your script will continue fine. However to make it run without that warning you need to add a compiler directive at the top.

Add the following line to get rid of that error.
#compiler_plugin_funcs = _ZipCreate, _ZipOtherFunc


I hope this helps,
JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)


#13 Eru

Eru

    Wayfarer

  • Active Members
  • Pip
  • 57 posts

Posted 22 April 2007 - 01:11 AM

I've added that line, and the error is still popping up. :/

Another note: The script automatically exits when it gives that error and no zip file is made.

#14 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 22 April 2007 - 01:45 AM

copy the dll to the directory with the script in it.
I have a seperate dir in my includes folder called "user" where i place include files that aren't installed with autoit. This is where I place the "_ZipPlugin.au3" file. However most people just place it in "includes". The example script is coded with the _ZipPlugin.au3 being in the production Includes folder with all the other includes. If you are using Beta then you'll need a copy placed there too.

At the top of _ZipPlugin.au3 is the compiler directives to ignore the plugin function names.

If you could post the exact error, it would go a long ways towards fixing you problem.

eltorro

Edited by eltorro, 22 April 2007 - 01:47 AM.


#15 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 26 April 2007 - 08:40 AM

I think I have just come across a bug in Apache webserver.


I have had a couple of reports of corrupt downloads and indeed it happend to me for both of the links.

I found that I can rename the file anything but Au3Zip.zip and it is perfectly fine. Even Au3zip.zip is fine.

Needless to say I have changed the name and re-uploaded the files.

eltorro

#16 smashly

smashly

  • Active Members
  • PipPipPipPipPipPip
  • 1,636 posts

Posted 26 April 2007 - 09:28 AM

Thank you for the update and name fix, I've really been enjoying using your plugin :(

Sorry to be totally off subject , but a similar thing happened to me lately.
I don't mean the apache server part , but the filename part.
Have you ever tried to create a file or folder in windows xp and just name it con ?
It just can't be done :shocked:
Bad luck if your name is con and you want a folder with your name on it...lol

#17 eltorro

eltorro

    more or less the same as the latter of the former.

  • Active Members
  • PipPipPipPipPipPip
  • 596 posts

Posted 28 April 2007 - 09:09 PM

I've updated the plugin please see first post.

A few changes.

;removed _ZipGetList()  ;replaced it with _ZipList2Array() functions below. ;Added: _ZipGetCount($ZipFileName) ;Get the number if items in the zip _ZipGetItemInfo($ZipFileName,$ItemIndex) ;Get ptr to info for a zip item. ;Added In the UDF: _ZipItemInfo2Array($ZipFileName,$ItemIndex) ;- 1 dim array of item info (single zip item) _ZipList2Array($ZipFileName) ;- 2 dim array of item info (dim 1 = zip item , dim 2 = item info ) _ZipGetList replacement.


eltorro

#18 Gene

Gene

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 494 posts

Posted 29 April 2007 - 10:55 PM

Thank you for the update and name fix, I've really been enjoying using your plugin :D

Sorry to be totally off subject , but a similar thing happened to me lately.
I don't mean the apache server part , but the filename part.
Have you ever tried to create a file or folder in windows xp and just name it con ?
It just can't be done :)
Bad luck if your name is con and you want a folder with your name on it...lol


Con is a reserved word, it goes back as far as DOS 2.11

You could use Kon, it would sound the same.

:D
Gene
Thanks for the response.GeneYes, I know the punctuation is not right...

#19 krawhitham

krawhitham

    Seeker

  • Active Members
  • 24 posts

Posted 21 May 2007 - 01:05 AM

this should work correct?

#Include <user/_ZipPlugin.au3> _ZipUnZip("dummy1.zip",@ScriptDir)


It compiles fine but gives unknown function error

#20 i542

i542

    Captain on the Bridge.

  • Active Members
  • PipPipPipPipPipPip
  • 1,821 posts

Posted 21 May 2007 - 04:55 PM

So of all the files in the .zip (by the way, it seems your ocotillo.sytes.net upload may be corrupted?), we only need _ZipPlugin.au3? None of the other *.c or *.dll files are needed, or do we need to fully extract all the contents of the .zip file into the script directory and rely on external .dll (and other?) files?

I'll try this out in a bit - if it's pure AutoIt, this looks great! :-)

Whoa, james, still here? Arent you the guy who helped me with my first problem?
i542
I can do signature me.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users