PureZIP library : ZIP / UNZIP files

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

Moderator: gnozal

User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Some Questions

1) How I can Create a Directory into the Archive ?
2) How I can Delete a File or Dir from Archive ?
3) How I can Add a File to a specified Folder into Archive ?

3) e.g.

C:\TestFolder\MyProg.exe ----> ZIP:\OtherFolder\Here\MyProg.exe

Or have I oversee some features ? I want use your lib in my current
project FileMaster (a Total-Commander Clone) and it works
fine. but I have some problems (commented on Top)
I missing a Destination$ for AddFile(s) and so on.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AL90 wrote:1) How I can Create a Directory into the Archive ?
You can't. I am not sure this is possible with the ZLIB functions I use (zipOpenNewFileInZip / zipWriteInFileInZip).
AL90 wrote:2) How I can Delete a File or Dir from Archive ?
You can't. ZLIB doesn't provide any function to do this. You have to recreate the archive.
AL90 wrote:3) How I can Add a File to a specified Folder into Archive ?
You can't. I am not sure this is possible with the ZLIB functions I use (zipOpenNewFileInZip / zipWriteInFileInZip).

FYI, I use this ZLIB package : http://www.winimage.com/zLibDll/
There are other libraries you could use like InfoZIP : http://www.info-zip.org/
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Ok I will use for the first time only the DeCompress Funktions of your Lib.
Later I will check another solutions. Thanks for your post and the Links. :wink:
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

PureZIP 1.70 BETA

Added UNICODE support.

Much code has changed, so it's a beta release.
Please test (ANSI and UNICODE) and report any bugs.
Thanks.

Download the beta here : http://people.freenet.de/gnozal/PureZIP_BETA.zip
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
mk-soft
Always Here
Always Here
Posts: 6207
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Post by mk-soft »

PureZIP 1.60

Hi,

I have follow probleme. When i Addfiles(...) with PureZIP_Recursive than have the archiv a folder entry and a file entry to the folder. That is not right.

My system is XP-Home

Thanks

Nice Day :wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

mk-soft wrote:PureZIP 1.60
I have follow probleme. When i Addfiles(...) with PureZIP_Recursive than have the archiv a folder entry and a file entry to the folder. That is not right.
Do you use #PureZIP_RecursiveZeroDirs or #PureZIP_Recursive ?

#PureZIP_Recursive : only files entries

Code: Select all

myFileinfo.PureZIP_FileInfo
PureZIP_AddFiles("c:\PureBasic400\Program\!!!.zip", "c:\PureBasic400\Program\PurePOP3_Debugfile\*.*" , #True, #PureZIP_Recursive)
If PureZIP_Archive_Read("c:\PureBasic400\Program\!!!.zip")
  ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
  While ReturnValue = #UNZ_OK 
    Debug PureZIP_Archive_FileInfo(@myFileinfo)
    Debug "Filename: " + myFileinfo\FileName
    Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
    Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
    ReturnValue.l = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\In_00001.mai
Compressed Size: 810
Uncompressed Size: 1950
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\PurePOP3-DEBUG-COM.txt
Compressed Size: 979
Uncompressed Size: 2384
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\PurePOP3-DEBUG-RETR-000.txt
Compressed Size: 838
Uncompressed Size: 1982
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\PurePOP3-TEST-DUMP.19
Compressed Size: 1602
Uncompressed Size: 3244
#PureZIP_RecursiveZeroDirs : also folder entries

Code: Select all

myFileinfo.PureZIP_FileInfo
PureZIP_AddFiles("c:\PureBasic400\Program\!!!.zip", "c:\PureBasic400\Program\PurePOP3_Debugfile\*.*" , #True, #PureZIP_RecursiveZeroDirs)
If PureZIP_Archive_Read("c:\PureBasic400\Program\!!!.zip")
  ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
  While ReturnValue = #UNZ_OK 
    Debug PureZIP_Archive_FileInfo(@myFileinfo)
    Debug "Filename: " + myFileinfo\FileName
    Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
    Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
    ReturnValue.l = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\
Compressed Size: 2
Uncompressed Size: 0
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\In_00001.mai
Compressed Size: 810
Uncompressed Size: 1950
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\PurePOP3-DEBUG-COM.txt
Compressed Size: 979
Uncompressed Size: 2384
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\PurePOP3-DEBUG-RETR-000.txt
Compressed Size: 838
Uncompressed Size: 1982
0
Filename: c:\PureBasic400\Program\PurePOP3_Debugfile\PurePOP3-TEST-DUMP.19
Compressed Size: 1602
Uncompressed Size: 3244
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 »

No feedback for the beta 1.70 so I assume it works well.

PureZIP 1.70

Changes :
- Added UNICODE support (ZLIB still works with ANSI strings).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Jacobus
Enthusiast
Enthusiast
Posts: 139
Joined: Wed Nov 16, 2005 7:51 pm
Location: France
Contact:

Post by Jacobus »

Hi gnozal,
Have you an example to add and to remove one password at file zip with your library, please ? I can't do it
PureBasicien tu es, PureBasicien tu resteras.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Jacobus wrote:Hi gnozal,
Have you an example to add and to remove one password at file zip with your library, please ? I can't do it
You can create a ZIP file with a password or read a ZIP file with a password, but not "remove one password at file zip".

Just use PureZIP_SetArchivePassword() before the other functions.

Example : Create ZIP with password

Code: Select all

PureZIP_SetArchivePassword("MyPassword")
If PureZIP_Archive_Create("MyZIP.zip", #APPEND_STATUS_CREATE)
  Debug PureZIP_Archive_Compress("MyFile.txt", #False)
  PureZIP_Archive_Close()
EndIf
Example : Read ZIP with password

Code: Select all

PureZIP_SetArchivePassword("MyPassword")
If PureZIP_Archive_Read("MyZIP.zip")
  ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
  While ReturnValue = #UNZ_OK 
    Debug PureZIP_Archive_FileInfo(@myFileinfo.PureZIP_FileInfo)
    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).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Some question:

It is normal that "PureZIP_AddFiles()" returns false if a File with 0-Bytes is copied ?

I have add your lib successfully in my project but I have remove If/Endif
because my Tool will display (own) ErrorMessage if a file with 0-Bytes was copied.

BTW:

Some chances for add a Delete/Rename Funktion in further updates of your lib and a optional DestPath$ parameter for AddFile(s) ?

Thanks for your lib, its great. :wink:
User avatar
Jacobus
Enthusiast
Enthusiast
Posts: 139
Joined: Wed Nov 16, 2005 7:51 pm
Location: France
Contact:

Post by Jacobus »

Just use PureZIP_SetArchivePassword() before the other functions.
Ok, i didn't know where to put itself. Thanks.
PureBasicien tu es, PureBasicien tu resteras.
User avatar
mk-soft
Always Here
Always Here
Posts: 6207
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Post by mk-soft »

Now Update to Version 1.70

That is right :D
a file entry to exist no longer the same folder entry :wink:

But I found the next problem. The germany files and foldern names with "äöü" are not right in a zip file.

FF :wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

mk-soft wrote:But I found the next problem. The germany files and foldern names with "äöü" are not right in a zip file.FF :wink:
It's a ZLIB problem.
Did you try the PureZIP_AsciiDosLatinUS_To_AsciiWinLatin1() function ?
From PureZIP.chm wrote:Translate a string from ASCII DOS Latin US to ASCII WIN Latin 1.

Usefull when compacting files with non english filenames (with french accents for example).

Original filename : "essai_é_à_ï_ù_è_ç.pb"
In ZIP archive : "essai_‚_…_‹_-_Š_‡.pb" (ZLIB don't use the correct page code)
Transformed with this function : "essai_é_à_ï_ù_è_ç.pb"
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 »

AL90 wrote:Some question:
It is normal that "PureZIP_AddFiles()" returns false if a File with 0-Bytes is copied ?
Yes
AL90 wrote:I have add your lib successfully in my project but I have remove If/Endif because my Tool will display (own) ErrorMessage if a file with 0-Bytes was copied.
If you wish more control when using PureZIP, please use the PureZIP_Archive_* functions. Then you can decide what file to add or not, what error message display etc...
AL90 wrote:Some chances for add a Delete/Rename Funktion in further updates of your lib and a optional DestPath$ parameter for AddFile(s) ?
Probably not, because there is no ZLIB function for this. You have to unpack/repack the archive to do this.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
mk-soft
Always Here
Always Here
Posts: 6207
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Post by mk-soft »

Is a probleme with WinLatin because the user deflate the archiv with another program. I write a spezial automatic backup program.

:cry:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply