PureZIP library : ZIP / UNZIP files

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

zxtunes.com wrote:gnozal tell PureZip supports unpacking zip (RAW) archive without heading from memory
(1 file without zip a heading format)?
No, this is not supported.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
KIKI
Enthusiast
Enthusiast
Posts: 145
Joined: Thu Dec 28, 2006 11:49 am
Location: FRANCE

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by KIKI »

With PB 4.41
I don't arrive to store the relative path
ex:
C:\toto is the main directory
repfic = c:\toto\titi
PureZIP_AddFiles(MyZIP, repfic+"\banque.db", #PureZIP_StorePathRelative, #PureZIP_Recursive)
if i use
PureZIP_AddFiles(MyZIP, repfic+"\banque.db", #PureZIP_StorePathRelative, #PureZIP_RecursiveZeroDirs)
It's impossible to read archive after
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

2KiKI : I am getting the expected results here ...

Code: Select all

repfic.s = "C:\toto\titi"
MyZIP.s = "C:\TEST1.ZIP"
Debug PureZIP_AddFiles(MyZIP, repfic+"\banque.db", #PureZIP_StorePathRelative, #PureZIP_Recursive)
Debug : 1
Resulting archive C:\TEST1.ZIP : valid [tested with TotalCMD, 7-ZIP and WinRAR]
Archive listing : c:\TEST1.ZIP\banque.db

Code: Select all

repfic.s = "C:\toto\titi"
MyZIP.s = "C:\TEST2.ZIP"
Debug PureZIP_AddFiles(MyZIP, repfic+"\banque.db", #PureZIP_StorePathRelative, #PureZIP_RecursiveZeroDirs)
Debug : 1
Resulting archive C:\TEST2.ZIP : valid [tested with TotalCMD, 7-ZIP and WinRAR]
Archive listing : c:\TEST2.ZIP\banque.db

Your base directory is "C:\toto\titi", so if you choose #PureZIP_StorePathRelative, the paths are stored relative to it, i.e. no path stored for 'banque.db' (it's in the base directory).

Try this :

Code: Select all

repfic.s = "C:\toto"
Debug PureZIP_AddFiles(MyZIP, repfic+"\*.db", #PureZIP_StorePathRelative, #PureZIP_Recursive)
NB : if you want more control, you may use the PureZIP_Archive_*() functions.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 664
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by Kurzer »

Hello Gnozal,

what does a Result of -666 means for function PureZIP_Archive_Compress() ?
(sorry no example code this time)

Kind Regards, Kurzer
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2023: 56y
"Happiness is a pet." | "Never run a changing system!"
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

kurzer wrote:what does a Result of -666 means for function PureZIP_Archive_Compress() ?
(sorry no example code this time)
-666 is #PureZIP_CallbackStop.
PureZIP_SetCompressionCallback(*ProcedureAddress)

The callback is called in realtime during compression or decompression.

Procedure MyCallback(FileName.s, Progression.f, UserParam.l)
   ; FileName : current processed file (if applicable)
   ; Progression : progression percentage)
   ProcedureReturn #False
   ; ProcedureReturn #True to stop the compression
EndProcedure

Returned value [only for PureZIP_Archive_Compress() and PureZIP_Archive_Extract()]
  #FALSE : compression / extraction continues
  #TRUE : compression / extraction stops !
    PureZIP_Archive_Compress() and PureZIP_Archive_Extract() returns #PureZIP_CallbackStop error
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 664
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by Kurzer »

Uhh damn, thank you for this hint! :shock:
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2023: 56y
"Happiness is a pet." | "Never run a changing system!"
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by IdeasVacuum »

Hi Gnozal

PB 4.40 x86 WinXP SP3

Can you spare some time to help me?

Using three simple Pure_Zip functions I create an archive with just one file inside (that is all I need):

PureZIP_Archive_Create(sMyZipFilePathFull, #APPEND_STATUS_CREATE)
PureZIP_AddFile(sMyZipFilePathFull, sMyFilePathFull, #PureZIP_StorePathAbsolute)
PureZIP_Archive_Close()

A zip file is created (archived file size is correct, 1,219,434 bytes) and I can open it with WinZip, WinRar etc but I cannot extract the file.

WinZip reports:

Extracting file: C:\Temp\Leg2-Small.zip
Extracting to "C:\Temp\"
Use Path: yes Overlay Files: no
Error in file #1: bad Zip file offset (Error local header signature not found): disk #1 offset: 0

WinRar:

! C:\Temp\Leg2-Small.zip: The archive is corrupt

PureZIP_ExtractFiles(sMyZipFilePathFull, "*.*", "C:\Temp", #TRUE) does not work either.

This is the same with or without storing the file path, thread safe mode or not. What am I doing wrong?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

IdeasVacuum wrote:Using three simple Pure_Zip functions I create an archive with just one file inside (that is all I need):
PureZIP_Archive_Create(sMyZipFilePathFull, #APPEND_STATUS_CREATE)
PureZIP_AddFile(sMyZipFilePathFull, sMyFilePathFull, #PureZIP_StorePathAbsolute)
PureZIP_Archive_Close()
A zip file is created (archived file size is correct, 1,219,434 bytes) and I can open it with WinZip, WinRar etc but I cannot extract the file.
You can't mix PureZIP_Archive_*() functions with 'standalone' functions like PureZIP_AddFile().
If you use PureZIP_Archive_Create(), you have to use PureZIP_Archive_Compress().
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by IdeasVacuum »

Owch! So obvious with hindsight! Sorry to waste your time. It's a magnificent library, thank you.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

IdeasVacuum wrote:Owch! So obvious with hindsight!
I have updated the help file :wink:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by DoubleDutch »

On PureBasic v4.50b2 there is a strange error:

Code: Select all

filename$=myFileinfo\FileName
Gives error: Can't write numerical value into a string variable.

But if I the structure as:

Code: Select all

Structure PureZIP_FileInfo2
  Version.l			; version made by
  VersionNeeded.l		; version needed to extract
  flag.l			; general purpose bit flag [if bit 0 is set the file is encrypted]
  CompressionMethod.l	; compression method [0 - 10]
  dosDate.l			; last mod file date in Dos format [do not use !]
  Crc32.l			; crc-32
  CompressedSize.l		; compressed size
  unCompressedSize.l	; uncompressed size
  SizeFilename.l		; filename length
  SizeFileExtra.l		; extra field length
  SizeFileComment.l		; file comment length
  DiskNumStart.l		; disk number start
  internal_fa.l		; internal file attributes
  external_fa.l		; external file attributes (packed file attributes)
  tmu_date.tm_date		; file date (see tm_date structure) [use this to get filedate!]
  FileName.s		; filename
EndStructure

myFileinfo.PureZIP_FileInfo2
It works.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
jamba
Enthusiast
Enthusiast
Posts: 144
Joined: Fri Jan 15, 2010 2:03 pm
Location: Triad, NC
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by jamba »

I've noticed the same thing as Double Dutch with 4.5b2. uninstall/reinstall of the userlib does not fix. somehow the structure definition is truncated.

(I made a post in the userlib thread, which turned out to be the wrong place!)
-Jon

Fedora user
But I work with Win7
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

DoubleDutch wrote:On PureBasic v4.50b2 there is a strange error:

Code: Select all

filename$=myFileinfo\FileName
Gives error: Can't write numerical value into a string variable.[/code]
I can't download PB4.50 right now, but iirc the structure is defined in PureZIP.res, so I suspect the new PB version doesn't read old residents correctly anymore ?
I will probably have to recompile the resident(s).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
dmxpowa
New User
New User
Posts: 2
Joined: Thu Jul 16, 2009 1:02 pm

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by dmxpowa »

id liek to ask for a file delete function, cuz if i do "AddFile" and the zip contains that file it just places it near the old item, produces 2 files with same name in the archive.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

dmxpowa wrote:id liek to ask for a file delete function, cuz if i do "AddFile" and the zip contains that file it just places it near the old item, produces 2 files with same name in the archive.
ZLIB does not provide any function to delete a file in an archive.
So this will not happen any time soon.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply