Page 32 of 40

Posted: Wed Jan 28, 2009 1:38 pm
by gnozal
PB wrote:So I assume the deflate algo is the default, then?
Yep !

Posted: Sat Jan 31, 2009 11:05 pm
by Fluid Byte
It's quite funny ...

Today I was looking for a possibility to load external files from a single archive into memory including password protection. So I remembered your userlib and just checked this thread. I thought it will be unusable since I avoid userlibs wherever I can but lucky for me, PureZIP is the only lib by you that is available as a shared library. :lol:

I just did some tests and everything is working fantastic. You are the greatest gnozal and I really appreciate all the effort you have put into this.

Keep up the great work! 8)

PureZip problem

Posted: Sun Feb 01, 2009 1:28 pm
by PB
This creates a zip file that Winzip v10.0 can't extract.
A bug, or my mistake? Does it happen for anyone else?
WinZip wrote:---------------------------
WinZip
---------------------------
Error in file #1: bad Zip file offset (Error local header signature not found): disk #1 offset: 0.
---------------------------
OK Help
---------------------------

Code: Select all

f$="c:\program files\internet explorer\iexplore.exe"
z$="c:\test.zip"

If PureZIP_Archive_Create(z$,#APPEND_STATUS_CREATE)
  PureZIP_AddFile(z$,f$,#PureZIP_DontStorePath)
  PureZIP_Archive_Close()
EndIf

Posted: Mon Feb 02, 2009 8:44 am
by gnozal
Fluid Byte wrote:Today I was looking for a possibility to load external files from a single archive into memory including password protection. So I remembered your userlib and just checked this thread. I thought it will be unusable since I avoid userlibs wherever I can but lucky for me, PureZIP is the only lib by you that is available as a shared library.
Yes, it was a request ... some PureZIP users don't use PB.
Anyway, I think you can transform almost any userlib into a DLL yourself by wrapping the userlib functions.

Re: PureZip problem

Posted: Mon Feb 02, 2009 8:52 am
by gnozal
PB wrote:This creates a zip file that Winzip v10.0 can't extract.
A bug, or my mistake? Does it happen for anyone else?
WinZip wrote:---------------------------
WinZip
---------------------------
Error in file #1: bad Zip file offset (Error local header signature not found): disk #1 offset: 0.
---------------------------
OK Help
---------------------------

Code: Select all

f$="c:\program files\internet explorer\iexplore.exe"
z$="c:\test.zip"

If PureZIP_Archive_Create(z$,#APPEND_STATUS_CREATE)
  PureZIP_AddFile(z$,f$,#PureZIP_DontStorePath) ; <------ ERROR
  PureZIP_Archive_Close()
EndIf
You have to use PureZIP_Archive_Compress() instead of PureZIP_AddFile() like in the PureZIP_Archive_Create() code example in the help file.

Code: Select all

If PureZIP_Archive_Create(MyZIP.s, #APPEND_STATUS_CREATE)
  Debug PureZIP_Archive_Compress(MyZIPFile1.s, #FALSE)
  Debug PureZIP_Archive_Compress(MyZIPFile2.s, #FALSE)
  PureZIP_Archive_Close()
EndIf
All PureZIP_Archive_*() functions work together, the other functions like PureZIP_AddFile() are standalone. You can't mix them.

Re: PureZip problem

Posted: Mon Feb 02, 2009 1:39 pm
by PB
Thanks!

Posted: Wed Feb 11, 2009 10:30 pm
by Fluid Byte
Is it possible to include a ZIP archive into the executable with IncludeBinary and then extract a single file from it into memory?

Posted: Thu Feb 12, 2009 9:16 am
by gnozal
Fluid Byte wrote:Is it possible to include a ZIP archive into the executable with IncludeBinary and then extract a single file from it into memory?
Not as binary include.
But you can attach your ZIP archive at the end of the executable (like a self-extracting archive). Then, you can extract a single file from it into memory.

Posted: Thu Feb 12, 2009 5:50 pm
by Fluid Byte
gnozal wrote:Not as binary include.
But you can attach your ZIP archive at the end of the executable (like a self-extracting archive). Then, you can extract a single file from it into memory.
Actually it's a little more complicated than that. I have a password-protected ZIP file which includes various other ZIP files which have to be extracted into memory. Any chance that such a functionality will be added anytime soon? Or is it possible to accomplish this with LZMA Lib?

If the original ZLIB offers such a feature I maybe could do it myself.

Posted: Fri Feb 13, 2009 8:38 am
by gnozal
Fluid Byte wrote:
gnozal wrote:Not as binary include.
But you can attach your ZIP archive at the end of the executable (like a self-extracting archive). Then, you can extract a single file from it into memory.
Actually it's a little more complicated than that. I have a password-protected ZIP file which includes various other ZIP files which have to be extracted into memory. Any chance that such a functionality will be added anytime soon?
The 'SFX' solution should also work with a password protected archive.
But embedded ZIP files ? No.
Fluid Byte wrote:Or is it possible to accomplish this with LZMA Lib?
Neither. But as I don't rely on a library (except for the compression), it might be possible to add this feature.
Fluid Byte wrote:If the original ZLIB offers such a feature I maybe could do it myself.
Iirc, ZLIB functions to read a ZIP archive (like unzOpen()) can only use a file, not a memory buffer. At least with the ZLIB version I use (original ZLIB modified by Gilles Vollant).

Posted: Tue Feb 17, 2009 10:41 am
by gnozal
gnozal wrote:
Fluid Byte wrote:
gnozal wrote:Not as binary include.
But you can attach your ZIP archive at the end of the executable (like a self-extracting archive). Then, you can extract a single file from it into memory.
Actually it's a little more complicated than that. I have a password-protected ZIP file which includes various other ZIP files which have to be extracted into memory. Any chance that such a functionality will be added anytime soon?
The 'SFX' solution should also work with a password protected archive.
But embedded ZIP files ? No.
@Fluid Byte : it looks like I was partially wrong !
For example this works :

Code: Select all

DataSection
  IncludeBinary "Test.zip"
EndDataSection

myFileinfo.PureZIP_FileInfo
If PureZIP_Archive_Read(ProgramFilename())
  ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
  While ReturnValue = #UNZ_OK 
    PureZIP_Archive_FileInfo(@myFileinfo)
    Debug "Filename: " + myFileinfo\FileName
    Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
    Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
    ReturnValue = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf

Posted: Tue Feb 17, 2009 2:30 pm
by Fluid Byte
Can't ..., describe ..., how ****ing awsome this is ... :shock:

gnozal > Fred! :P

Seriously, it works without a problem. I was afraid that only the ZIP could be included because it needs to be read from the end of the .EXE. But it seems, it doesn't matter where in your executable the archive is stored. It can even be in the middle because the memory is scanned until the ZIP-Header is found.

This works as well:

Code: Select all

IncludeFile "PureZIP.pbi"

InitSprite() : InitKeyboard()
OpenWindow(0,0,0,800,600,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,0,0,0)

CatchSprite(0,?pblogo)
CatchSprite(1,?geebee)

ArchiveFile$ = ProgramFilename()

Index = PureZIPDLL_FindFile(ArchiveFile$,"desert07_RT.jpg",1)
PureZIPDLL_GetFileInfo(ArchiveFile$,Index,pzfi.PureZIP_FileInfo)
lpData = AllocateMemory(pzfi\unCompressedSize)
PureZIPDLL_ExtractMemory(ArchiveFile$,Index,lpData,pzfi\unCompressedSize)

UseJPEGImageDecoder()
CatchSprite(2,lpData)

FreeMemory(lpData)

Repeat
	EventID = WindowEvent()
	
	ExamineKeyboard()
	ClearScreen($804020)
	DisplaySprite(0,10,10)
	DisplaySprite(1,10,85)
	DisplaySprite(2,200,85)
	FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or EventID = #PB_Event_CloseWindow

DataSection
	pblogo:
	IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\PureBasicLogo.bmp"	
	skybox:
	IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\skybox.zip"			
	geebee:
	IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\Geebee2.bmp"
EndDataSection
Thank you very much mate! Great LIB! :o

Posted: Tue Feb 17, 2009 9:33 pm
by PB
Fluid Byte wrote:gnozal > Fred! :P
BLASPHEMY! :lol:

Posted: Tue Feb 17, 2009 9:52 pm
by Fluid Byte
PB wrote:
Fluid Byte wrote:gnozal > Fred! :P
BLASPHEMY! :lol:
Ok, maybe not god but at least his trainee. :lol:

@gnozal:

I just discovered a weird bug. If you add UseOGGSoundDecoder() to my or your example the code will fail in both cases. I haven't found a way to get around this yet but maybe you can take a look.

Posted: Wed Feb 18, 2009 9:13 am
by gnozal
Fluid Byte wrote:@gnozal:
I just discovered a weird bug. If you add UseOGGSoundDecoder() to my or your example the code will fail in botch cases. I haven't found a way to get around this yet but maybe you can take a look.
It looks like a debugger issue !?
It works without it ... :shock: