Jump to content

Zip plugin


eltorro
 Share

Recommended Posts

I really needed to have compression Option

thanks

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

  • Replies 100
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

OK,

Just tried this too, Copied _ZipPlugin.au3 to the correct directory, (include\user), have the dll in the script directory that I'm creating, compile my script and get error _ZipCreate unknown function, I opened the _ZipPlugin.au3 and it doesn't contain a function called _ZipCreate. it looks like the functions have been deleted from the file.

Pebbles

Link to comment
Share on other sites

OK,

Just tried this too, Copied _ZipPlugin.au3 to the correct directory, (include\user), have the dll in the script directory that I'm creating, compile my script and get error _ZipCreate unknown function, I opened the _ZipPlugin.au3 and it doesn't contain a function called _ZipCreate. it looks like the functions have been deleted from the file.

Pebbles

Can you post your script? _ZipCreate is in the plugin dll, not the .au3 file.

Link to comment
Share on other sites

I really needed to have compression Option

thanks

It could not find the correct place to change the compression ratio. I ran several tests and none of them seemed to change the ratio any (even trying no compression).

Edited by eltorro
Link to comment
Share on other sites

this should work correct?

#Include <user/_ZipPlugin.au3>
_ZipUnZip("dummy1.zip",@ScriptDir)oÝ÷ Ø¢jbëwºØ"½ë.IèÂwîËb¢w«®ÿªê-xÚ-«p¢}ý·
+ç߶­¢(^iÔëÉ«­¢+Ø(%¹±Õ±ÐíÕÍȽ}i¥ÁA±Õ¥¸¹ÔÌÐì(ÀÌØí¡¹±ôA±Õ¥¹=Á¸¡MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈíÔÍi¥À¹±°ÅÕ½Ðì¤)¥ÀÌØí¡¹±Ñ¡¸(}i¥ÁU¹i¥À ÅÕ½ÐíÕµµäĹé¥ÀÅÕ½Ðì±MÉ¥ÁѥȤ)¹¥(
Link to comment
Share on other sites

  • 2 weeks later...

I've made a couple of updates, please see first post for links and edits.

Link to comment
Share on other sites

I must be missing something. I have tried every examble and read through everything in the downloaded zip, and I still cannot get it to create a zip file and add a file to it. I can get unzip to work but that is it. Could you give an example on how to create a zip file and then add a file to the zip file. thanks.

Icarri

Link to comment
Share on other sites

The files in the Au3Zip has a documented example.

I'm not at my devel machine so I can't look at it right now but I should get a chance within the next hour or so.

Link to comment
Share on other sites

I found a problem , fixed it and up loaded an new updated version. I called a zip check on the folder being added. So, the func would fail to add the folder.

The return codes from zip.h

// These are the result codes:
#define ZR_OK        0x00000000  // nb. the pseudo-code zr-recent is never returned,
#define ZR_RECENT    0x00000001  // but can be passed to FormatZipMessage.
// The following come from general system stuff (e.g. files not openable)
#define ZR_GENMASK  0x0000FF00
#define ZR_NODUPH    0x00000100  // couldn't duplicate the handle
#define ZR_NOFILE    0x00000200  // couldn't create/open the file
#define ZR_NOALLOC  0x00000300   // failed to allocate some resource
#define ZR_WRITE      0x00000400     // a general error writing to the file
#define ZR_NOTFOUND   0x00000500     // couldn't find that file in the zip
#define ZR_MORE    0x00000600    // there's still more data to be unzipped
#define ZR_CORRUPT  0x00000700   // the zipfile is corrupt or not a zipfile
#define ZR_READ    0x00000800    // a general error reading the file
// The following come from mistakes on the part of the caller
#define ZR_CALLERMASK 0x00FF0000
#define ZR_ARGS    0x00010000    // general mistake with the arguments
#define ZR_NOTMMAP  0x00020000   // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't
#define ZR_MEMSIZE  0x00030000   // the memory size is too small
#define ZR_FAILED    0x00040000  // the thing was already failed when you called this function
#define ZR_ENDED      0x00050000     // the zip creation has already been closed
#define ZR_MISSIZE  0x00060000   // the indicated input file size turned out mistaken
#define ZR_PARTIALUNZ 0x00070000     // the file had already been partially unzipped
#define ZR_ZMODE      0x00080000     // tried to mix creating/opening a zip
// The following come from bugs within the zip library itself
#define ZR_BUGMASK  0xFF000000
#define ZR_NOTINITED  0x01000000     // initialisation didn't work
#define ZR_SEEK    0x02000000    // trying to seek in an unseekable file
#define ZR_NOCHANGE   0x04000000     // changed its mind on storage, but not allowed
#define ZR_FLATE      0x05000000     // an internal error in the de/inflation code
Edited by eltorro
Link to comment
Share on other sites

Thanks for the fast reply. I notice the output that Autoit get is in decimal and the outputs you post are in hex. So I converted them and wrote a function to call to make logging easier. I am sure you have an easier way (I am not the greatest programer). It seems to work but I only test a view of the errors.

#Include <_ZipPlugin.au3>

$FPath = "c:\Log-" & @YEAR & @MON & @MDAY & ".txt";set log file and path
$BPath = "c:\SDB-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & ".zip";set file and path to backup too

_WriteLog($FPath,"Start Script.")

if (($handle = PluginOpen("C:\users\jhedrick.smart\desktop\scripts\Au3Zip.dll")) <> 0) Then
    $hFile = _ZipCreate($BPath)
    $v_ret = _ZipAdd($hFile,"C:\smart_be.mdb","smart_be.mdb")
    _LogZip()
    $v_ret = _ZipAdd($hFile,"C:\smart.mdb","smart.mdb")
    _LogZip()
    $v_ret = _ZipClose($hFile)
    _LogZip()
EndIf

PluginClose($handle)

Func _WriteLog($FilePath,$Text)
    $File = FileOpen($FilePath,9)
    FileWriteLine($File,@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " " & $Text)
    FileClose($File)
EndFunc

Func _LogZip()
    If $v_ret = 0 Then;;nb. the pseudo-code zr-recent is never returned,
        _WriteLog($FPath,"Zip Function Successfull")
    ElseIf $v_ret = 256 Then;; couldn't duplicate the handle
        _WriteLog($FPath,"ERROR:Zip - Could't duplicate the handle.")
    ElseIf $v_ret = 512 Then;; couldn't create/open the file
        _WriteLog($FPath,"ERROR:Zip - Could't create/open the file.")
    ElseIf $v_ret = 768 Then;; failed to allocate some resource
        _WriteLog($FPath,"ERROR:Zip - Failed to allocate some resource.")
    ElseIf $v_ret = 1024 Then;; a general error writing to the file
        _WriteLog($FPath,"ERROR:Zip - A general error writing to the file.")
    ElseIf $v_ret = 1280 Then;; couldn't find that file in the zip
        _WriteLog($FPath,"ERROR:Zip - Couldn't find that file in the zip.")
    ElseIf $v_ret = 1536 Then;; there's still more data to be unzipped
        _WriteLog($FPath,"ERROR:Zip - There's still more data to be unzipped.")
    ElseIf $v_ret = 1792 Then;; the zipfile is corrupt or not a zipfile
        _WriteLog($FPath,"ERROR:Zip - The zipfile is corrupt or not a zipfile.")
    ElseIf $v_ret = 2048 Then;; a general error reading the file
        _WriteLog($FPath,"ERROR:Zip - A general error reading the file.")
    ElseIf $v_ret = 65536 Then;; general mistake with the arguments
        _WriteLog($FPath,"ERROR:Zip - General mistake with the arguments.")
    ElseIf $v_ret = 131072 Then;;tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't
        _WriteLog($FPath,"ERROR:Zip - Tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't.")
    ElseIf $v_ret = 196608 Then;;the memory size is too small
        _WriteLog($FPath,"ERROR:Zip - The memory size is too small.")
    ElseIf $v_ret = 262144 Then;;the thing was already failed when you called this function
        _WriteLog($FPath,"ERROR:Zip - The thing was already failed when you called this function.")
    ElseIf $v_ret = 327680 Then;;the zip creation has already been closed
        _WriteLog($FPath,"ERROR:Zip - The zip creation has already been closed.")
    ElseIf $v_ret = 393216 Then;;the indicated input file size turned out mistaken
        _WriteLog($FPath,"ERROR:Zip - The indicated input file size turned out mistaken.")
    ElseIf $v_ret = 524288 Then;;tried to mix creating/opening a zip
        _WriteLog($FPath,"ERROR:Zip - Tried to mix creating/opening a zip.")
    ElseIf $v_ret = 16777216 Then;;initialisation didn't work
        _WriteLog($FPath,"ERROR:Zip - Initialisation didn't work.")
    ElseIf $v_ret = 33554432 Then;;trying to seek in an unseekable file
        _WriteLog($FPath,"ERROR:Zip - Trying to seek in an unseekable file.")
    ElseIf $v_ret = 67108864 Then;;changed its mind on storage, but not allowed
        _WriteLog($FPath,"ERROR:Zip - Changed its mind on storage, but not allowed.")
    ElseIf $v_ret = 83886080 Then;;an internal error in the de/inflation code
        _WriteLog($FPath,"ERROR:Zip - An internal error in the de/inflation code.")
    EndIf
EndFunc;logzip()

Just thought I would share in case it helps someone else. Again thanks for the help.

Icarii

Link to comment
Share on other sites

There is a builtin function to give you the return code's associated message:

_ZipFormatMessage ($return_code)

Is it not working for you??

Edit: Yours are a bit more descriptive.

Edited by eltorro
Link to comment
Share on other sites

There is a builtin function to give you the return code's associated message:

CODE: AutoIt_ZipFormatMessage ($return_code)

Is it not working for you??

Well, I did not see that. Bet that could of saved me some time. Oh, well. My script seems to be working, but I am still testing. Thanks for the response.

Icarii

Link to comment
Share on other sites

How do I install this plugin?

Put the dll in a folder where your script will find it. If your distributing you script, you could put it in the script dir.

There is an include file, _ZipPlugin.au3 add this to your project.

Edit: The include file has compiler directive to prevent the compiler from not recognizing the plugin function names, and it provides a couple of methods to assist using the plugin.

There is an example program called PluginZip.au3 that shows the use of plugin.

Edited by eltorro
Link to comment
Share on other sites

eltorro, great UDF. As always, you do great work.

Any chance that CodeProject has 7zip functions available?

Thanks,

I haven't checked lately, but not last time I checked , no 7zip.

I suppose it would be possible to wrap the commandline version into a dll. Maybe I wll look into this in the future.

Link to comment
Share on other sites

First of all thanks, works great.

I noticed when adding a directory to a zip, that there is very heavy CPU load just prior to actually starting the zip process. The durration of this load increases with the size of and/or number of files in directory being added. It seems that while it is in this state there is no pausing it either i.e. throwing a sleep into and adlib call. Is there away to reduce the CPU load durring that time.

Regards,

Mike

Link to comment
Share on other sites

First of all thanks, works great.

I noticed when adding a directory to a zip, that there is very heavy CPU load just prior to actually starting the zip process. The durration of this load increases with the size of and/or number of files in directory being added. It seems that while it is in this state there is no pausing it either i.e. throwing a sleep into and adlib call. Is there away to reduce the CPU load durring that time.

Regards,

Mike

The plugin code is using a recursive dir search to get the file names, so I would expect some loading. How many files are you talking about? It's probably possible to throw some sleep into the function without to much effort. As for pausing the action, right now it is not possible as there is not any mouse or keyboard support in the plugin. I'll look into adding some kind of handler.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...