PureZIP library : ZIP / UNZIP files

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

Moderator: gnozal

User avatar
Frontier
User
User
Posts: 74
Joined: Thu Dec 22, 2005 2:43 pm
Location: Chios, Greece
Contact:

Post by Frontier »

Inner wrote:4.30 beta 2 & 3 of Purebasic reports;

The following PureLibrary is missing: StringExtension
Hi,

All gnozal's libraries expose this error, it has to do with differences in PB 4.30b2. When gnozal recompiles his libraries for PB 4.30b2 (or final) the error will disappear.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

But will Gnozal be able to compile libs for PureBasic x64?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Post by Sveinung »

Will PureZip be able to compress locked files?

Regards
Sveinung
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Locked files? As in files that are in use by other programs?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Sveinung wrote:Will PureZip be able to compress locked files?
If PB's function ReadFile() can open your locked files, then probably yes. Otherwise no.
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 »

Tip : how to get a ZIP archive comment with PureZIP using ZLIB function unzGetGlobalComment()

Code: Select all

;
; How to get the ZIP archive comment (if any)
;
Import "" ; maybe I add it in the next PureZIP version ....
  unzGetGlobalComment(zipFile.l, *global_comment, CommentBufLen.l) As "_unzGetGlobalComment@12"
EndImport

hZIP = PureZIP_Archive_Read("MyZIP.zip")
If hZIP
  If PureZIP_Archive_GlobalInfo(@GlobalInfo.unz_global_info) = #UNZ_OK
    If GlobalInfo\size_comment
      *Comment = AllocateMemory(GlobalInfo\size_comment)
      If *Comment
        If unzGetGlobalComment(hZIP, *Comment, GlobalInfo\size_comment)
          Debug PeekS(*Comment, GlobalInfo\size_comment) ; <--- archive comment
        EndIf
        FreeMemory(*Comment)
      EndIf
    EndIf
  EndIf
  PureZIP_Archive_Close()
EndIf
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

gnozal wrote:Tip : how to get a ZIP archive comment with PureZIP using ZLIB function unzGetGlobalComment()
Thanks a lot! Image

Greetings ... Kiffi
Hygge
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Gnozal, I have found a fix for that #APPEND_STATUS_CREATEAFTER bug (the one that overwrites the SFX module).

In ZIP.C, in the zipOpen2() function, after this line:

Code: Select all

init_linkedlist(&(ziinit.central_dir));
Add this:

Code: Select all

    if (append == APPEND_STATUS_CREATEAFTER)
    {
      if (ZSEEK(ziinit.z_filefunc,ziinit.filestream,0,ZLIB_FILEFUNC_SEEK_END))
       {
         ZCLOSE(ziinit.z_filefunc,ziinit.filestream);
         return NULL;
       }
    } 
Source:
http://forum.winimage.com/viewtopic.php?p=785&
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Inf0Byt3 wrote:Gnozal, I have found a fix for that #APPEND_STATUS_CREATEAFTER bug (the one that overwrites the SFX module).
Thanks.
I knew there was a fix on the forum, but the official package was never updated.
I only used the static library from the ZLIB package, I didn't compile the sources. Unfortunately, I have only (very) little experience with C, so if you (or Fizban [he already compiled a working (with PB) ZLIB static library]) could compile the fixed sources, it would be great.
Anyway, it's still possible to create a SFX : simply copy the ZIP file after the EXE. That's what I do for my library installer.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Don't have much experience either, but managed to build the new lib. However, please test it well before using. I'm not an expert :(.

I compiled it using the project in \contrib\vstudio\vc8\. When I tested it, it was showing a PB linker error with __time64 or someting like that because PB doesn't know that symbol. To fix it I removed "#include <time.h>" from the source and now VC assumes it's an 'int". The code is included in case you'll need it in the future.

So the modifications are:
1. Fix that bug in Zip.c with append
2. Remove time.h so the lib can be imported without hacks in PB

Download link:

http://purebasic.myftp.org/?filename=fi ... n_v123.zip

Let me know if there are any problems :).
Anyway, it's still possible to create a SFX : simply copy the ZIP file after the EXE. That's what I do for my library installer.
Yup, but this time i wanted to make it work without any temp files :).
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Thanks.
I made some tests, it seems to work !
I have compiled a test library [PB4.20 ANSI] : http://freenet-homepage.de/gnozal/PureZ ... dFixed.zip
Could you test it carefully to see if something got broken ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

I've made some tests with it and seems to work with no problems (XP SP3) with all the examples in the manual (from the original PureZip package). It would be great if others would test it as well, just in case.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (All PB versions + DLL)

Changes :
- recompiled with a fixed static ZLIB [thanks Inf0Byt3].
It fixes the #APPEND_STATUS_CREATEAFTER issue. The rest should work as usual.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

Frontier wrote:
Inner wrote:4.30 beta 2 & 3 of Purebasic reports;

The following PureLibrary is missing: StringExtension
Hi,

All gnozal's libraries expose this error, it has to do with differences in PB 4.30b2. When gnozal recompiles his libraries for PB 4.30b2 (or final) the error will disappear.
Hi gnozal,
Did you fix this error?How fix this error?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

sec wrote:
Frontier wrote:
Inner wrote:4.30 beta 2 & 3 of Purebasic reports;
The following PureLibrary is missing: StringExtension
Hi,
All gnozal's libraries expose this error, it has to do with differences in PB 4.30b2. When gnozal recompiles his libraries for PB 4.30b2 (or final) the error will disappear.
Hi gnozal,
Did you fix this error?How fix this error?
The libs will be recompiled with PB4.30 final.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply