Yep !PB wrote:So I assume the deflate algo is the default, then?
PureZIP library : ZIP / UNZIP files
Moderator: gnozal
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
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.
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!
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.

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!

Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
PureZip problem
This creates a zip file that Winzip v10.0 can't extract.
A bug, or my mistake? Does it happen for anyone else?
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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Yes, it was a request ... some PureZIP users don't use PB.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.
Anyway, I think you can transform almost any userlib into a DLL yourself by wrapping the userlib functions.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureZip problem
You have to use PureZIP_Archive_Compress() instead of PureZIP_AddFile() like in the PureZIP_Archive_Create() code example in the help file.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
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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureZip problem
Thanks!
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Is it possible to include a ZIP archive into the executable with IncludeBinary and then extract a single file from it into memory?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Not as binary include.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?
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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
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?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.
If the original ZLIB offers such a feature I maybe could do it myself.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
The 'SFX' solution should also work with a password protected archive.Fluid Byte wrote: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?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.
But embedded ZIP files ? No.
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:Or is it possible to accomplish this with LZMA Lib?
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).Fluid Byte wrote:If the original ZLIB offers such a feature I maybe could do it myself.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
@Fluid Byte : it looks like I was partially wrong !gnozal wrote:The 'SFX' solution should also work with a password protected archive.Fluid Byte wrote: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?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.
But embedded ZIP files ? No.
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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Can't ..., describe ..., how ****ing awsome this is ...
gnozal > Fred!
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:
Thank you very much mate! Great LIB! 

gnozal > Fred!

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

Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Ok, maybe not god but at least his trainee.PB wrote:BLASPHEMY!Fluid Byte wrote:gnozal > Fred!

@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.
Last edited by Fluid Byte on Wed Feb 18, 2009 12:40 pm, edited 1 time in total.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
It looks like a debugger issue !?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 works without it ...

For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).