7Zip extraction code needed

Everything else that doesn't fall into one of the other PB categories.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

7Zip extraction code needed

Post 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.
Last edited by Fangbeast on Fri Jan 30, 2015 7:39 am, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: 7Zip extraction code needed

Post by heartbone »

Keep it BASIC.
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Re: 7Zip extraction code needed

Post 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.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: 7Zip extraction code needed

Post by ts-soft »

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: 7Zip extraction code needed

Post 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.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: 7Zip extraction code needed

Post by Fangbeast »

ts-soft wrote:7-zip
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:)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: 7Zip extraction code needed

Post 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
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: 7Zip extraction code needed

Post 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.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: 7Zip extraction code needed

Post 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)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: 7Zip extraction code needed

Post 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!
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: 7Zip extraction code needed

Post by Bisonte »

Code: Select all

ReadProgramData()
ReadProgramError()
ReadProgramString()
Don't forget that these functions have an ASCII output... (if your compilerflag "unicode" is set)
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
JHPJHP
Addict
Addict
Posts: 2258
Joined: Sat Oct 09, 2010 3:47 am

Re: 7Zip extraction code needed

Post 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.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: 7Zip extraction code needed

Post 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
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: 7Zip extraction code needed

Post 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.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
JHPJHP
Addict
Addict
Posts: 2258
Joined: Sat Oct 09, 2010 3:47 am

Re: 7Zip extraction code needed

Post 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

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Post Reply