Zip plugin

101 posts in this topic

Posted (edited)

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

Share this post


Link to post
Share on other sites



Posted

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! :-)

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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:

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

this should work correct?

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

It compiles fine but gives unknown function error

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.