PureLZMA : compress/uncompress data using LZMA algo

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

besko
User
User
Posts: 42
Joined: Tue Oct 28, 2008 1:08 pm

Post by besko »

How to write SFX packer with this lib Gnozal :) Tnx
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

besko wrote:How to write SFX packer with this lib Gnozal :) Tnx
A quick (basic) example :
1. Create the SFX stub :

Code: Select all

;
; EXE stub example
; 
If PureLZMA_Archive_ReadSFX(ProgramFilename())
  ArchiveInfo.LZMA_ArchiveInfo
  If PureLZMA_Archive_FindFirst()
    ;
    PureLZMA_Archive_GetArchiveInfo(@ArchiveInfo)
    ; Extract file to exe directory
    PureLZMA_Archive_Extract(GetPathPart(ProgramFilename()) + GetFilePart(ArchiveInfo\FileName))
    ;
    While PureLZMA_Archive_FindNext()  
      ;
      PureLZMA_Archive_GetArchiveInfo(@ArchiveInfo)
      ; Extract file to exe directory
      PureLZMA_Archive_Extract(GetPathPart(ProgramFilename()) + GetFilePart(ArchiveInfo\FileName))
      ;
    Wend
  EndIf
  ;
  PureLZMA_Archive_Close()
EndIf
; Compile as SFX.exe
2. Create the SFX (adds compressed data to the stub) :

Code: Select all

;
; Create SFX
; 
If PureLZMA_Archive_CreateSFX("SFX.exe")
  PureLZMA_Archive_Compress(#PB_Compiler_Home + "Catalogs\Compiler.catalog", #False)
  PureLZMA_Archive_Close()
Else
  MessageRequester("ERRROR", "Could not open SFX stub !", #MB_ICONERROR)
EndIf
3. Execute SFX.exe, it will extract 'Compiler.catalog' to the current directory
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
besko
User
User
Posts: 42
Joined: Tue Oct 28, 2008 1:08 pm

Post by besko »

big Tnx Gnozal :)
neotoma
User
User
Posts: 84
Joined: Sun Dec 14, 2003 6:38 pm
Location: Germany, Mechernich
Contact:

Post by neotoma »

Great Userlib !

Would it be possible to get it as static-Lib + import-Include ?
I have a prob with userlibs, since every new PB-Version change something.
(I hope the include of static-Libs would stay longer.. :-) )

Mike
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

neotoma wrote:I have a prob with userlibs, since every new PB-Version change something.
(I hope the include of static-Libs would stay longer.. :-) )
Imho a MSCOFF static lib [if the PB Compiler would support it] would not last longer (as a userlib is basically a static lib).
I have added a DLL version : http://freenet-homepage.de/gnozal/PureLZMA_DLL.zip
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (PB4.30 userlib)

Changes
- added PureLZMA-Packer-Mem library in the PureLZMA package.
It allows to read PureLZMA archives included in data sections.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

gnozal wrote:- added PureLZMA-Packer-Mem library in the PureLZMA package.
It allows to read PureLZMA archives included in data sections.
You are godlike gnozal! :shock:

Do you want money for that? I would pay! 8)
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Fluid Byte wrote:You are godlike gnozal! :shock:
There is only one god ...
... srod !

Ok, maybe two with Sparkie.

:D
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Both false! It's Fred! :shock:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Hello gnozal,

I use following procedure but I got a problem:

Code: Select all

Procedure.l GetCryptedStateLZMA(ArcFile$)

If PureLZMA_Archive_Read(ArcFile$)
  ArchiveInfo.LZMA_ArchiveInfo
  Status = PureLZMA_Archive_FindFirst()
  While Status
    If PureLZMA_Archive_GetArchiveInfo(@ArchiveInfo)
      x = ArchiveInfo\LZMAFlags
      If x = #LZMA_Flag_Crypted
        Break
      EndIf
    EndIf
    Status = PureLZMA_Archive_FindNext()
  Wend
  PureLZMA_Archive_Close()
EndIf

ProcedureReturn x

EndProcedure

debug GetCryptedStateLZMA("D:\Temp\Archive.arc")
If the Archive is crypted, the returned value is '3'. but the doc says
the returned value is '2'. can it be that the doc is wrong ?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AL90 wrote:If the Archive is crypted, the returned value is '3'. but the doc says the returned value is '2'. can it be that the doc is wrong ?
I assume the record is packed [#LZMA_Flag_Compressed] and crypted [#LZMA_Flag_Crypted], so flags = #LZMA_Flag_Crypted | #LZMA_Flag_Compressed (= 3 <> #LZMA_Flag_Crypted).
You should test it like this : x & #LZMA_Flag_Crypted.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

You right. This way will work now. I have so mistake the doc.
Thanks for quoting.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

New version compiled with PB4.40 BETA 1 : http://freenet-homepage.de/gnozal/PureLZMA_440.zip
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: PureLZMA : compress/uncompress data using LZMA algo

Post by jassing »

Is there a way to use a callback for large files to display a progress bar?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureLZMA : compress/uncompress data using LZMA algo

Post by gnozal »

jassing wrote:Is there a way to use a callback for large files to display a progress bar?
No.
PureLZMA uses LzmaCompress() and LzmaUnCompress(), without any streaming features.
I didn't try to use the other LZMA library functions : I'm not very good at C(++).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply