Page 1 of 2
7Zip extraction code needed
Posted: Fri Jan 30, 2015 2:43 am
by Fangbeast
Looking through the forum, there are lots of broken links so I am wondering if anyone has any 7zip extraction code handy.
Specifically, I am trying to extract a single file from a PortableApps format archive (Which PB ZIP cannot open) and haven't found anything.
Has anyone still got a working copy of TS-Soft's includes for PB (Or similar)? The integrated approach is what I want to do.
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 3:10 am
by heartbone
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 9:44 am
by graves
Hi FangBeast,
I've a "PureLZMA-500-Installer.exe" but not using, I don't know if it's functional on 5.31, if you need it I can upload and send you a link.
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 11:09 am
by ts-soft
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 12:37 pm
by Fangbeast
graves wrote:Hi FangBeast,
I've a "PureLZMA-500-Installer.exe" but not using, I don't know if it's functional on 5.31, if you need it I can upload and send you a link.
Graves, that sounds to be one of Gnozal's old libs right? if that's right, it might work on 5.24 but not on 5.31.
Thanks for the offer.
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 12:39 pm
by Fangbeast
Thanks ts-soft, thought your stuff was lost forever. When I tested PB's internal 7zip support, it didn't open my file and I went looking for the compression format which turned out to me LZMA:25 and 7zip itself worked on it.
Will be trying your code out now instead of sleeping:)
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 1:08 pm
by Fangbeast
PB.5.24 LTS tested. x86
PB.5.31 tested. x86
Just tested some example code of TS-Soft's from the forum. On a PortableApps archive, no handle is aquired so the listing fails. 7zip opens and lists it quite fine.
I created a native 7zip archive from my pb files and a handle is aquired opening the archive (so dll's libs etc, must be in the right directory) but instead of filenames, a whole string of 65's are displayed?
Don't know where to go from here.
Code: Select all
CurrentDirectory.s = GetCurrentDirectory()
XIncludeFile "7-zip_Include.pbi"
Define.l HARC = SevenZipOpenArchive(0, CurrentDirectory.s + "Address Book U3 v1.15.7z", #ARCEXTRACT_OPEN)
Debug HARC
Define.INDIVIDUALINFO INFO
If HARC
If Not SevenZipFindFirst(HARC, "*.*", @INFO)
Debug INFO\szFileName
While Not SevenZipFindNext(HARC, @INFO)
Debug INFO\szFileName
Wend
EndIf
SevenZipCloseArchive(HARC)
EndIf
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 1:24 pm
by PureGuy
Why don't you simply use 7za.exe?
What ts-soft posted is very old and will not support LZMA2, which is the new standard compression for 7z files.
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 1:32 pm
by Fangbeast
PureGuy wrote:Why don't you simply use 7za.exe?
What ts-soft posted is very old and will not support LZMA2, which is the new standard compression for 7z files.
I'd rather have 7zip integrated than have to shell out to the command line from pb. It's alright for a 1 off (or even a 2 off!!) but when I used the 'shell' method in the past with things like this, I'd often adapt the code to open/read thousands of archives and there has always been a serious memory/resource leak on my machines from windows 7 to 8 to 8.1 to 10.
Never did find out why but it was a windows thing.
P.s. I'm also not familiar with getting information back from an external EXE into PB where I could display it. (Embarrassed look. Never done it yet)
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 7:50 pm
by bbanelli
Fangbeast wrote:P.s. I'm also not familiar with getting information back from an external EXE into PB where I could display it. (Embarrassed look. Never done it yet)
Perhaps try with this?
http://www.purebasic.com/documentation/ ... index.html
ReadProgramData()
ReadProgramError()
ReadProgramString()
There are also some useful tips and suggestions regarding Data vs. String here on forum from guys, make sure you go through them!
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 9:05 pm
by Bisonte
Code: Select all
ReadProgramData()
ReadProgramError()
ReadProgramString()
Don't forget that these functions have an ASCII output... (if your compilerflag "unicode" is set)
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 9:48 pm
by JHPJHP
Hi Fangbeast,
PureGuy wrote:What ts-soft posted is very old and will not support LZMA2, which is the new standard compression for 7z files
I redid the Interface to the latest libraries, and documentation suggests that LZMA2 is supported; you may have better luck with this new version?
-
http://www.purebasic.fr/english/viewtop ... 12&t=61534
NB*: I haven't added any examples yet, but I will when time permits.
Re: 7Zip extraction code needed
Posted: Fri Jan 30, 2015 10:10 pm
by Fangbeast
JHPJHP wrote:Hi Fangbeast,
PureGuy wrote:What ts-soft posted is very old and will not support LZMA2, which is the new standard compression for 7z files
I redid the Interface to the latest libraries, and documentation suggests that LZMA2 is supported; you may have better luck with this new version?
-
http://www.purebasic.fr/english/viewtop ... 12&t=61534
NB*: I haven't added any examples yet, but I will when time permits.
I'll have a go at it after shopping today, have several 'styles' of 7zip compressed files to try it on. Your useful help is appreciated
Re: 7Zip extraction code needed
Posted: Sat Jan 31, 2015 7:22 am
by Fangbeast
Okay, tried it. Can open the archive I created with 7zip but cannot open the PortableApps EXE archive. Says "Cannot open 'foo.exe' as archive.
7zip itself can open it and definately lists the compression format for those as LZMA:25 so I don't know what I am missing.
Re: 7Zip extraction code needed
Posted: Sat Jan 31, 2015 11:31 pm
by JHPJHP
Hi Fangbeast,
I'm sorry to say that packed executables are not supported. The interface has the same functionality as the 7-zip command line tool (7za.exe): 7z and zip.
- this means that a command line interface is also not an option