[PB 5.10 B1] UnpackMemory

Just starting out? Need help? Post your questions and find answers here.
ThoPie
User
User
Posts: 47
Joined: Sat Aug 22, 2009 6:49 pm

[PB 5.10 B1] UnpackMemory

Post by ThoPie »

Hi,

first a big "Thank You" for PureBasic 5.10 beta 1.
I use UnpackMemory() in my project. PB 5.10 b1 says "UnpackMemory is not a function, array, list, map or macro!".
Is this a bug or is something changed?
Thanks.

ThoPie
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB 5.10 B1] UnpackMemory

Post by Fred »

The whole packer lib has been changed. You need to use:

UseZipPacker() and/or UseLZMAPacker() and/or UseBriefLZPacker() and then Un/CompressMemory(), or the Pack commands (it handle ZIP archive creation and manipulation and 7z archive unpack (no creation).

A small sample to get you started:

Code: Select all

UseLZMAPacker()

*a = AllocateMemory(10000)
*b = AllocateMemory(100000)

Debug CompressMemory(*a, 10000, *b, 100000)
Debug UncompressMemory(*b, 100000, *a, 10000)

If OpenPack(0, "Test.7z")
  Debug "cool !"
  
    
  If ExaminePack(0)
    Debug "ok"
    
    While NextPackEntry(0)
      
      Debug PackEntryName(0)
      Debug PackEntryType(0)
      Debug PackEntrySize(0)
      Debug PackEntrySize(0, 1)
      
    Wend
  EndIf
  
  Debug UncompressPackFile(0, "yo_unicode.pdf", "test.pdf")
  
  ClosePack(0)
  
EndIf
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: [PB 5.10 B1] UnpackMemory

Post by User_Russian »

How to find out required buffer size "*Output" function UncompressMemory()?
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB 5.10 B1] UnpackMemory

Post by Fred »

It's not stored in the compressed buffer, so you need to store it yourself somewhere (you can put it in the front of your compressed buffer if you want).
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: [PB 5.10 B1] UnpackMemory

Post by User_Russian »

Fred wrote:It's not stored in the compressed buffer
The experiment showed that when using UseBriefLZPacker(), is stored in the buffer size, not compressed data.

Code: Select all

UseBriefLZPacker()

String.s = "CompressMemory+UseBriefLZPacker()"+
           "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
           "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Debug Hex(StringByteLength(String))
*Out = AllocateMemory($1000)

x=CompressMemory(@String, StringByteLength(String), *Out, $1000)

If x
  Debug Hex(PeekL(*Out+8))
  ShowMemoryViewer(*Out, x)
EndIf
Maybe it's useful to someone.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB 5.10 B1] UnpackMemory

Post by Fred »

You should not rely on that, as it could change. If there is no PB function to retrieve the size, you should not try guessing.
Post Reply