I need help using the zLib file commands
Posted: Sun Feb 03, 2013 3:31 pm
I want to use the file commands of the zlib (zip packer library shipped with PureBasic), but I stuck at the point where the file structure gzFile_s is needed.
Is someone out there who has used successfully this file commands in PureBasic? (Gnozal? PureZIP library?)
I would be glad for some helpful hints.
Thanks in advance.
Kurzer
Here is my testcode. It produce a "Invalid memory access" error.
Is someone out there who has used successfully this file commands in PureBasic? (Gnozal? PureZIP library?)
I would be glad for some helpful hints.
Thanks in advance.
Kurzer
Here is my testcode. It produce a "Invalid memory access" error.
Code: Select all
EnableExplicit
; I don't know how to convert this C structure to PB
; zlib.h
; struct gzFile_s {
; unsigned have;
; unsigned char *Next;
; z_off64_t pos;
; };
; zconf.h
; # Define z_off64_t z_off_t
; # Define z_off_t long
; This seems to be wrong
Structure gzFile_s
have.i
*Next
pos.l
EndStructure
Global sOutFile.s, sFileMode.s, sText.s
Global *InBuffer, *Filehandle.gzFile_s
Import "zlib.lib"
gzclose(a.i) As "_gzclose"
gzopen(a.i, b.i) As "_gzopen"
gzwrite(a.i, b.i, c.i) As "_gzwrite"
EndImport
sOutFile = "F:\Out.txt"
sFileMode = "wb9"
sText = "01234567890123456789"
*InBuffer = @sText
; I want to write 10 Byte of the String sText into the compressed gzFile "Out.txt"
*Filehandle = gzopen(@sOutFile, @sFileMode)
Debug *Filehandle
If *Filehandle <> 0
; The following Instructuion stop with an "Invalid memory access"
Debug Str(gzwrite(*Filehandle, *InBuffer, 10))
gzclose(*Filehandle)
EndIf
