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:

Post by gnozal »

Update (both libs and DLL)

Changes :

- PureZIP now stores filenames with slash (like on Unix based systems) instead of backslash (like on Windows).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (PB4.0x lib and DLL)

Changes :

- fixed broken unicode support (since V1.90)
- cleaned-up code
I hope it's all ok now ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Password protect error

Post by Micko »

Hi gnozal
i use purezip to password protect some files but when i try open these files with win rar, i see only the first file corrupt.
if it's one file protect by password, this one always corrupt :shock:
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Password protect error

Post by gnozal »

Micko wrote:Hi gnozal
i use purezip to password protect some files but when i try open these files with win rar, i see only the first file corrupt.
if it's one file protect by password, this one always corrupt :shock:
I can't confirm. I just tested it this way :

Code: Select all

; Create encrypted ZIP
If PureZIP_Archive_Create("c:\test.zip", #APPEND_STATUS_CREATE)
  PureZIP_SetArchivePassword("password")
  PureZIP_Archive_Compress("c:\PureBasic400\Examples\PureZIP\PureZIP_TEST_1.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Examples\PureZIP\PureZIP_TEST_2.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Examples\PureZIP\PureZIP_TEST_3.pb", #False)
  PureZIP_Archive_Close()
EndIf
Checked "c:\test.zip" in WinRAR and TotalCMD -> OK
Extracted files -> OK
Maye be some more details would help ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

> Maye be some more details would help ?
yes i use this code.

Code: Select all

nom_archive.s= "Archive.zip"
PureZIP_Archive_Create("C:\"+ nom_archive, #APPEND_STATUS_CREATE);
PureZIP_SetArchivePassword("password")
PureZIP_AddFiles("C:\"+ nom_archive,"C:\Temp\*.*" , #PureZIP_StorePathRelative ,#PureZIP_Recursive)
PureZIP_Archive_Close()
the fist file is always corrupt
"C:\Temp\" i have a lot of files and folders in this folder
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Micko wrote:> Maye be some more details would help ?
yes i use this code.

Code: Select all

nom_archive.s= "Archive.zip"
PureZIP_Archive_Create("C:"+ nom_archive, #APPEND_STATUS_CREATE);
PureZIP_SetArchivePassword("password")
PureZIP_AddFiles("C:"+ nom_archive,"C:\Temp\*.*" , #PureZIP_StorePathRelative ,#PureZIP_Recursive)
PureZIP_Archive_Close()
the fist file is always corrupt
"C:\Temp" i have a lot of files and folders in this folder
Your code is false.
It should be like this :

Code: Select all

nom_archive.s= "Archive.zip"
; PureZIP_Archive_Create("C:"+ nom_archive, #APPEND_STATUS_CREATE) ; use ONLY with PureZIP_Archive_* functions, like PureZIP_Archive_Compress() etc...
PureZIP_SetArchivePassword("password")
PureZIP_AddFiles("C:"+ nom_archive,"C:\Temp\*.*" , #PureZIP_StorePathRelative ,#PureZIP_Recursive)
; PureZIP_Archive_Close() ; use ONLY with PureZIP_Archive_* functions
Tested the corrected code with a folder containing 3792 files (-> 79 Mb archive) ; no problem with WinRAR or TotalCMD (test archive or extract) ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

thanks gnozal this work but i have an other problem.
in my "C:\Temp\" folder i have compressor.exe file and other file. After zip these files when i try to execute the exe "compressor.exe n'est pas une application WIN32 valide" message appear.

i use your last code[/code]
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Micko wrote:thanks gnozal this work but i have an other problem.
in my "C:\Temp" folder i have compressor.exe file and other file. After zip these files when i try to execute the exe "compressor.exe n'est pas une application WIN32 valide" message appear.
i use your last code
I don't understand ...
Compressor.exe is in the archive, the archive check is ok, and yet if you extract it the exe is not valid ?
Again, without source, what can I do ?
Note : what version of PB are you using ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

Sorry gnozal its ok now. thanks a lot for your support.
but how can i get the size of archive files not archive size.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

Micko wrote:Sorry gnozal its ok now. thanks a lot for your support.
but how can i get the size of archive files not archive size.
PureZIP_Archive_FileInfo(*FileInfo.PureZIP_FileInfo)
PureZIP_FileInfo\CompressedSize.l
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Bonne_den_kule wrote:
Micko wrote:Sorry gnozal its ok now. thanks a lot for your support.
but how can i get the size of archive files not archive size.
PureZIP_Archive_FileInfo(*FileInfo.PureZIP_FileInfo)
PureZIP_FileInfo\CompressedSize.l
Yes, that's it.

Code: Select all

PureZIP_Archive_FileInfo(*FileInfo.PureZIP_FileInfo) 

Description

Get file information from current file in current archive.

Parameter

Structure PureZIP_FileInfo
  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

Structure tm_date
 tm_sec.l			; seconds after the minute - [0,59]
 tm_min.l			; minutes after the hour - [0,59]
 tm_hour.l			; hours since midnight - [0,23]
 tm_mday.l		; day of the month - [1,31]
 tm_mon.l			; months since January - [0,11]
 tm_year.l			; years - [1980..2044]
EndStructure
See PureZIP_Archive_FileInfo() help for more details.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

gnozal i use this but it's return the size of each file. if i want the total of all archive files how can i proceed ?
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Micko wrote:gnozal i use this but it's return the size of each file. if i want the total of all archive files how can i proceed ?

Code: Select all

Procedure.l GetDirectorySizeZIP(ZipFile$,Dir$)

TotalSize.q=0
FileInfo.PureZIP_FileInfo
If PureZIP_Archive_Read(ZipFile$)
  ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
  While ReturnValue = #UNZ_OK 
    If PureZIP_Archive_FileInfo(@FileInfo) = #UNZ_OK
      a$="ZIP:"+FileInfo\Filename
      If LCase(Left(a$,Len(Dir$)))=LCase(Dir$) And Right(a$,1)<>""
        TotalSize+FileInfo\unCompressedSize & $FFFFFFFF
      EndIf
    EndIf
    ReturnValue = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf

ProcedureReturn TotalSize

EndProcedure

Debug GetDirectorySizeZIP("c:\test.zip","")
;Debug GetDirectorySizeZIP("c:\test.zip","ZIP:\SubFolder")
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

@ AL90
you are welcome
thanks a lot :D
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

Hi gnozal
when i compress folder include application, setup and text files everything is ok but when extracting these files the exe seems corrupt. :(
Post Reply