Page 1 of 1

[PB 5.10 B1] UnpackMemory

Posted: Fri Dec 21, 2012 7:18 pm
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

Re: [PB 5.10 B1] UnpackMemory

Posted: Fri Dec 21, 2012 7:29 pm
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

Re: [PB 5.10 B1] UnpackMemory

Posted: Fri Feb 08, 2013 7:26 pm
by User_Russian
How to find out required buffer size "*Output" function UncompressMemory()?

Re: [PB 5.10 B1] UnpackMemory

Posted: Fri Feb 08, 2013 7:29 pm
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).

Re: [PB 5.10 B1] UnpackMemory

Posted: Fri Feb 08, 2013 8:22 pm
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.

Re: [PB 5.10 B1] UnpackMemory

Posted: Fri Feb 08, 2013 11:01 pm
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.