Jump to content

7Zip


rasim
 Share

Recommended Posts

one request though, could you please add a version or date to the UDF, so tracking updates would be easier?

I think this not it is necessary, because mistakes are corrected only.

Edit:

Taking a deeper look, should the _OnAutoitExit() func be called manually on Exit? Don't see it being done. Also you wrote IsDeclared("$hDLL_7ZIP"), I think it should be IsDeclared("hDLL_7ZIP").

Damn! I'm very unattentive. Thank you! Fixed :)
Link to comment
Share on other sites

Hmmm, this way you silently override an OnAutoItExit() func defined by the user. Wouldn't something like

Opt("OnExitFunc","OnAutoItExit")

global $old_opt = Opt("OnExitFunc","OnAutoItExit_7Zip")

GUICreate("test", 230, 90)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then ExitLoop
    sleep(5)
WEnd

Func OnAutoItExit()
    MsgBox(0,'','Org OnAutoItExit func')
EndFunc

Func OnAutoItExit_7Zip()
    call($old_opt)
    MsgBox(0,'','7Zip OnAutoItExit func')
EndFunc

be nicer? Or point out at top of the UDF that the user somehow has to include your exit func in his own like

Func OnAutoItExit()
    MsgBox(0,'','Org OnAutoItExit func')
    OnAutoItExit_7Zip()
endfunc

...not sure about this, just random thoughts :)...

Btw, do you now a switch to preserve folder path information in the zip? Couldn't find it (yet)....

Best Regards

Link to comment
Share on other sites

Btw, do you now a switch to preserve folder path information in the zip? Couldn't find it (yet)....

-r switch when adding or updating files makes it recursive.

for extracting with full paths you can use

x command to extract with full paths.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Archiving in subdirs is the path information. I don't think you're going to be able to save a path like "C:\Program Files\blah\blah" in an archive. It's going to be relative paths to the root of your extraction. Then as suggested use the 'x' command to extract full paths, relative to your extraction root.

Link to comment
Share on other sites

Archiving in subdirs is the path information. I don't think you're going to be able to save a path like "C:\Program Files\blah\blah" in an archive. It's going to be relative paths to the root of your extraction. Then as suggested use the 'x' command to extract full paths, relative to your extraction root.

Tried that :) , can't archive what I want. I want to pack files incl. there relative path (not the absolute one), e.g. like in this example:

#include<7Zip.au3>

FileCopy('c:\windows\system32\rundll32.exe',@ScriptDir & '\windows\systemTEST\',9)

_7ZipAdd(0,@ScriptDir & '\test.zip','c:\windows\system32\rundll32.exe',0,5,1)
_7ZipAdd(0,@ScriptDir & '\test.zip',@ScriptDir & '\windows\systemTEST\rundll32.exe',0,5,1)

_7ZIPExtract(0,@ScriptDir & '\test.zip',@ScriptDir,0,0,1)
_7ZIPExtractEx(0,@ScriptDir & '\test.zip',@ScriptDir,0,0,1)

The files should go to

'\windows\system32\' and

@scriptdir & '\windows\systemTEST\'

in the archive,

and my desired result would be to extract them to

@scriptdir & '\windows\system32\' and

@scriptdir & @scriptdir & '\windows\systemTEST\'

But it doesn't work this way.

My problem is, that I want to pack files from different dirs with the same filename. But the code above won't pack two files like lets say

c:\windows\system32\rundll32.exe and

c:\windows\system\rundll32.exe

into the same archive. It would overwrite the first file in the archive (or skip packing it, depending on the params). And neiter of the extraction functions unpacks incl. relative path.

Thanks for your suggestions so far.... Best Regards

Edit: Updated example

Edited by KaFu
Link to comment
Share on other sites

I think to do what you want you'll need to artificially create your directory structure, ie -

<base_dir>

\windows\system32\rundll32.exe

\windows\systemTEST\rundll32.exe

then

_7ZipAdd(0,@ScriptDir & '\test.zip',@ScriptDir & "\<base_dir>",0,5,1)

assuming that function will recursively add a directory (I didn't look at the UDF, but you get the idea). I don't think there's any archiver that will do exactly what you're asking. They're all based off a single base directory, then relative paths of files / folders underneath.

Edited by wraithdu
Link to comment
Share on other sites

to artificially create your directory structure

Yeah, that would be a workaround, but I fear with inferior speed. Want to use it for SMF, so that you can filter on any files, regardless of their location, and add them to an archive. And during testing I was confronted with this issue. But on the otherhand I don't want to move files (even though maybe unnoted) this way on my 'clients' pc.

They're all based off a single base directory, then relative paths of files / folders underneath.

At least 7-zip (and this issue is clearly a .dll issue) and zipfldr.dll seem to behave this way, guess I'll search and test other open-source packers.

Thanks for you're input... and rasim for this great plugin :)...

Best Regards

Link to comment
Share on other sites

  • 2 weeks later...

When I try to use the udf, I get an error about an undeclared variable

Z:\AutoIt3\Include\7Zip.au3 (744) : ==> Variable used without being declared.:

If $hArchiveProc Then DllCallbackFree($hArchiveProc)

If ^ ERROR

I downloaded and installed latest autoit and 7zip versions.

Link to comment
Share on other sites

I went looking inside the 7zip.au3.

I saw no problem with the variable.

It is properly declared as a global (at beginning in the file).

Beats me why the error appears then :)

What I did see is that in the beginning, it tries to open 7-zip32.dl in the script folder.

Global $hDLL_7ZIP = DllOpen(@ScriptDir & "\7-zip32.dll")
l

I tried to find this file in my 7zip installation (4.65) but couldn't find it.

So I googled and downloaded a version (3.11.0.1)

So I placed the requested file in my script dir.

And yes, now it works :)

Link to comment
Share on other sites

  • 2 weeks later...

I am having a serious problem I can't fix myself..... the udf author is needed here! :)

The script crashes without any obvious reason. Here the message the box in SciTe shows and below the part of code where it happens:

>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "J:\Coding\Caravelle v3.5\Builds\Caravelle3_Setup.au3" 
!>15:21:42 AutoIT3.exe ended.rc:-1073741819
>Exit code: -1073741819 Time: 70.444

If Not FileExists($path & "\Icons\Caravelle³.ico") Then
    $text &= "Extracting Icon Library..." &@CRLF
    GUICtrlSetData($info, $text)
    $sizeArc = _7ZipGetFileCount($f_IconLib_file);;;;; This is the line where the script crashes!!! The next line is not executed, the line before is.
    $retResult = _7ZipSetOwnerWindowEx($ui_fg, "_ARCHIVERPROC")
    If $retResult = 0 Then
        MsgBox(16, "", "Error occured")
    ;Exit
    EndIf
    $retResult = _7ZIPExtractEx($ui_fg, $f_IconLib_file, $path & "\Icons", 1)
EndIf

Please help me! :)

[font="Courier New"]http://RomanK.hondadesigns.com[/font]
Link to comment
Share on other sites

I've been trying for the past 2 hours to figure out how to extract only a certain filetype(*.tif) from an archive. Could someone provide a working example ?

#include <7Zip.au3>
$ArcFile = FileOpenDialog("Select archive", "", "Archive Files (*.7z;*.zip;*.gzip;*.bzip2;*.tar)")
If @error Then Exit
$hArc = _7ZipOpenArchive(0, $ArcFile)
If $hArc = 0 Then Exit MsgBox(16, "_7ZipOpenArchive", "Error occured")
_7ZIPExtract(0,$ArcFile,0,0,0,1,'','','*.tif')
_7ZipCloseArchive($hArc)
Edited by KaFu
Link to comment
Share on other sites

  • 2 weeks later...

Thanks!

But now I need something else... I've tried to figure this out by myself again. I'm trying to archive specific files types: *.xml, *.ssi, *.spi, *.hdt, *.sst and *.png I was only able to specify 2 files type using

$FileName = $Output & "\*.png"

$sInclude="*.xml"

;Add Files to Archive

$retResult = _7ZipAdd(0, $ArcFile, $FileName, 0, 5, 1, $sInclude)

Any thoughts ?

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I keep getting:

Line 744 (File "C:\Users\Zach\Documents\au\7Zip\7Zip.au3"):

If $hArchiveProc Then DllCallbackFree($hArchiveProc)

If ^ ERROR

Error: Variable used without being declared.

-------

Windows Vista Home Premium, sp 0.

Am I missing a file or something? Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Hello, all. I'm new here, so please take it easy on me. ^_^

I've read through this thread from the start and despite a couple mentions on the first page starting with rasim, it isn't clear whether these user-defined functions will work with the latest version of 7za.dll (official 7-Zip Library). Rasim links to a rather ancient discussion of problems with a much older version of the DLL. GEOSoft seems to have had some experience with 7za.dll, but doesn't specify which versions or how long ago he's tried. A much more recent mention of the use of the DLL that I found with a google search seems to confirm some difficulties in its "Known Issues" section, yet further down states the following:

Important Update: Starting from 7-Zip 4.46 alpha Igor did necessary changes in the code. So, from this version forward, you can use format DLLs directly, without applying any patch.

Personally, I'm just interested in a more recent version than the one linked in rasim's first post which is over two and a half years old.
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...