Posted: Wed Jan 28, 2009 1:38 pm
Yep !PB wrote:So I assume the deflate algo is the default, then?
http://www.purebasic.com
https://www.purebasic.fr/english/
Yep !PB wrote:So I assume the deflate algo is the default, then?
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
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.
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
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?
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.
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.
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.
@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.
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
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
BLASPHEMY!Fluid Byte wrote:gnozal > Fred!
Ok, maybe not god but at least his trainee.PB wrote:BLASPHEMY!Fluid Byte wrote:gnozal > Fred!
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.