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 »

PAMKKKKK wrote::oops: I dont remark that gnozal hasn´t made any choice to change compression mode......
Yes, gnozal is a bit busy right now ... Perhaps for the next version.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PAMKKKKK
User
User
Posts: 18
Joined: Sun May 01, 2005 7:55 am
Location: Germany Braunschweig
Contact:

Post by PAMKKKKK »

Stay cool 8) 8) 8) !

I love you for your hard work!! Especially on jaPBe !!

Thanks ...
Develop Standards, and you develop the World!
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

gnozal wrote:
webbmeister wrote:Look folks, you will have to bear with me on this. Im not a beginner as far as general programming technique is concerned, but in terms of using libs & dlls etc and where to put them, I am a big clueless.
What I want to do is ZIP c:\test.txt to c:\test.zip. I am using version 4 beta 7. A simple working example would be great + which lib files / dlls do I need to place where.
I know it's a lot to ask :wink:
DLL in the same directory than the EXE
Libraries in %Purebasic%\PureLibraries\UserLibraries
Ok, in my purebasic folder I have the following..

purebasic\purelibraries\userlibraries\Purezip_L
purebasic\purelibraries\userlibraries\Purezip_O
purebasic\purelibraries\userlibraries\Purezip_W

puebasic\zlibwapi.dll (42k File??? I've seen a larger file with the same name elsewhere!!!)

Is this correct, because when I try to compile the following code (apparantly working code copied from an earlier post).....

Code: Select all

myzip.s = "c:\purebasic393\program\PureZIP-test.zip"
myzipfile1.s = "C:\PureBasic393\Program\PureCOLOR_TEST_2.pb"
myzipfile2.s = "C:\PureBasic393\Program\PureCOLOR_TEST_3.pb"
OpenConsole()
If PureZIP_Archive_Create(myzip.s, #APPEND_STATUS_CREATE)
  PureZIP_Archive_Compress(myzipfile1.s, #False)
  PureZIP_Archive_Compress(myzipfile2.s, #False)
  PureZIP_Archive_Close()
EndIf
CloseConsole()
I get the following error.....

Line 5: Constant not found: #APPEND_STATUS_CREATE

Any Ideas?
PAMKKKKK
User
User
Posts: 18
Joined: Sun May 01, 2005 7:55 am
Location: Germany Braunschweig
Contact:

Post by PAMKKKKK »

@webbmeister
Why you are using PB4 ?? IT IS BETA !!! And Buggy !!!
And most of the Userlibraries are not ported to work with PB4 !
(Some are going never to be ported :cry: )

if i try to compile the given example, il get the error "Missing libraryExtensions", so it runs here even not.

You can Install PB 3.94 and PB 4beta parallel (each in a seperate Dir).

Use PB 3.94 the difference are not so great for you as a coder (most advantages of PB4 are undercover....) :wink:
Develop Standards, and you develop the World!
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

Managed to get the Zip example working at last! with PB4 B7 . Thanks for all the help everyone.
How do I get the zip routine to cope with filenames that contain non standard characters. "Café.txt" for example becomes "CafÚ.txt" when zipped.
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

Also, How do I get a "before" and "after" filesize for a zip file?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

@webbmeister : did you read the PureZIP help files ?
1. For your accent problem (Café.txt), see PureZIP_AsciiDosLatinUS_To_AsciiWinLatin1()
2. For the file sizes, see PureZIP_Archive_FileInfo() , and the PureZIP_FileInfo structure members CompressedSize and unCompressedSize.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

Thanks Gnozal, will check that out.
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

I've read the help file & tried to compile the examples (which do not work) If I copy the example code for "ASCIILATINDOS...." from the help file into the source code "NUM 3 - 12/03/2006" it will not compile - I get "structure not found PureZIP_fileinfo". Getting really frustrated with all this, A few working :? examples and i would be on my way! Sorry if I sound annoyed, but Im not good at second guessing code.[/i]
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

You can't mix code and expect it to work.
Either use PureZIP with PB3.94 (will be updated for PB4.00 final) or Num3's code with DLL with PB4.00 beta.
And please note this is a PureZIP thread : post coding questions in the appropriate forum 'Coding Questions' http://www.purebasic.fr/english/viewforum.php?f=13
Thanks.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

gnozal wrote:You can't mix code and expect it to work.
Either use PureZIP with PB3.94 (will be updated for PB4.00 final) or Num3's code with DLL with PB4.00 beta.
And please note this is a PureZIP thread : post coding questions in the appropriate forum 'Coding Questions' http://www.purebasic.fr/english/viewforum.php?f=13
Thanks.
I think I get it now. It's hard to grasp at first how all the versions and dlls gel together. Are there any examples out there for ASCIItoLATIN on num 3?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

webbmeister wrote:I think I get it now. It's hard to grasp at first how all the versions and dlls gel together. Are there any examples out there for ASCIItoLATIN on num 3?
Here's the code :

Code: Select all

 INLINE ASM !
; Conversion  AsciiDosLatinUS vers AsciiWinLatin1 (caractères accentuées)
; par Denis (Forum Français)
Procedure AsciiDosLatinUS_To_AsciiWinLatin1(StringPointer.l) ; Transforms a string from ASCII DOS Latin US to ASCII WIN Latin 1
  ; Ex: AsciiDosLatinUS_To_AsciiWinLatin1(@MaChaine.s)
  ;
  ! LEA Ebx, [TableConversion]
  MOV Ecx, StringPointer
  ! Boucle :
  ! MOV al, byte [Ecx]
  ! TEST al, al
  ! JZ FinChaine
  ! CMP  al, $80
  ! JNA  CarSuivant
  ! ADD  al, -$80
  ! XLATB
  ! MOV  byte[Ecx], al
  ! CarSuivant:
  ! INC Ecx
  ! JMP Boucle
  ;  
  ; table des 128 caractères de remplacement
  ;
  ! TableConversion:
  ! DB $C7, $FC, $E9, $E2, $E4, $E0, $E5, $E7, $EA, $EB, $E8, $EF, $EE, $EC, $C4, $C5
  ! DB $C9, $E6, $C6, $F4, $F6, $F2, $FB, $F9, $FF, $D6, $DC, $A2, $A3, $A5, $20 ,$83
  ! DB $E1, $ED, $F3, $FA, $F1, $D1, $AA, $BA, $BF, $20, $AC, $BD, $BC, $A1, $AB, $BB
  ! DB $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
  ! DB $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
  ! DB $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
  ! DB $20, $DF, $20, $20, $20, $20, $B5, $20, $20, $20, $20, $20, $20, $20, $20, $20
  ! DB $20, $B1, $20, $20, $20, $20, $F7, $20, $B0, $20, $B7, $20, $20, $B2, $20, $20
  ! FinChaine:
EndProcedure
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

Thanks gnozal, you're a star!!
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

I have come across a strange problem with the ZIP_TEST Routine.
If I put the unzip part of the routine inside a loop, so that I can unzip multiple files. The first 10 runs are OK and the zip files report correct name/size etc. The 10th time, It doesn't matter which zip file you select, it always reports that it contains no files. Below is how I have modified the ZIPTEST porcedure. I suspect this is a buffer issue somewhere? any ideas?

Code: Select all

Procedure ZIP_TEST(); Small procedure to test the procedures

  If ZIP_Lib_Init()


    ;****  Create Zip File **********
    ;MessageRequester("Message","Select a new zip filename to create")




    Goto jumper
    file.s="c:\test.zip"
    ; MessageRequester("message",file.s)

    If file
      add_file.s="c:\test.txt"

      If add_file

        ;  MessageRequester("message",add_file)

        Handle.l=ZIP_FileCreate(file,#APPEND_STATUS_CREATE)

        If Handle

          ;  MessageRequester("Message","Select a file to insert into the zip")


          If ZIP_FileAdd(Handle,add_file,GetFilePart(add_file))


            Debug "File Added to Archive..."

          EndIf


          ZIP_FileClose(Handle)

        EndIf

      EndIf


    EndIf
    End
    jumper:
   zip_lib_init()

    file.s=OpenFileRequester("Select a Zip","*.zip","Zip|*.zip",0)

    If file

      myFileinfo.unz_file_info

      Count.l=ZIP_FileCount(file)
      Debug "This zip has " + Str(Count) + " itens"

     ; out_path.s=PathRequester("Extracto to:" ,"d:\temp")
      For a=0 To Count-1

        ZIP_GetFileInfo(file,a,@myFileinfo)
        Filesize.l=myFileinfo\uncompressed_size

        If Filesize>0

          Debug "Filename: " + myFileinfo\FileName
          Debug "Compressed Size: " + Str(myFileinfo\compressed_size)
          Debug "Uncompressed Size: "+ Str(Filesize)

         ; If ZIP_ExtractFile(file,a,out_path,#False)
            ;Debug "File Extracted"
         ; EndIf
          Debug "***************"

        Else
          Debug "Directory: " + myFileinfo\FileName
          Debug "***************"
        EndIf

      Next

    EndIf



    ZIP_Lib_Stop()
    
    Goto jumper
    
  EndIf
  
  End
EndProcedure
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Sorry, I don't know the zip package you are using, it does not seem to be PureZIP. Maybe the author can help ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply