PureZIP library : ZIP / UNZIP files

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

Moderator: gnozal

zikitrake
Addict
Addict
Posts: 868
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

:( another bug

If you have a zip file with 2 files with the same name in differents directories,

For example, you have this tree directory

c:\test\text.txt
c:\test\dir1\text.txt

Code: Select all

Searchfile1.s = "c:\test\text.txt"
ReturnValue1.l = PureZIP_FindFile(ZIPFile$, SearchFile1)

Searchfile2.s = "c:\test\dir1\text.txt"
ReturnValue2.l = PureZIP_FindFile(ZIPFile$, SearchFile2)
ReturnValue1 and ReturnValue2 have the same value (I think it only search for filename without path)

And I would like that

Code: Select all

PureZIP_Archive_Locate()
can Returns file number in archive or add the command

Code: Select all

PureZIP_Archive_FindFile(FileToSearch.s)
(is this possible?)

Thank you!!
PB 6.21 beta, PureVision User
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes
- Fixed archived file date bug
- Fixed some errors in help files and improved documentation
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 »

@zikitrake : I will see what I can do.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
zikitrake
Addict
Addict
Posts: 868
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

gnozal wrote:@zikitrake : I will see what I can do.
Very thank you for your effort!
PB 6.21 beta, PureVision User
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

If you have a zip file with 2 files with the same name in differents directories,
ReturnValue1 and ReturnValue2 have the same value (I think it only search for filename without path)
Yes, I search only for the filename.
I will add an option to search for the full path.
And I would like that PureZIP_Archive_Locate() returns file number in archive
I simply use the ZLIB unzLocateFile() function wich does not work that way.
And PureZIP_Archive_Locate() is intended to work like the other PureZIP_Archive_*() functions, ie with current file in archive.

But you can do your own FindFileInZIP() function :
- open archive with PureZIP_Archive_Read()
- scan the archive with the PureZIP_Archive_FindFirst() / PureZIP_Archive_FindNext() functions
- and get the file info (including Filename) with PureZIP_Archive_FileInfo
- do what you have to do with the FileName
- close archive with PureZIP_Archive_Close()
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
zikitrake
Addict
Addict
Posts: 868
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

gnozal wrote:
And I would like that PureZIP_Archive_Locate() returns file number in archive
I simply use the ZLIB unzLocateFile() function wich does not work that way.
And PureZIP_Archive_Locate() is intended to work like the other PureZIP_Archive_*() functions, ie with current file in archive.

But you can do your own FindFileInZIP() function :
- open archive with PureZIP_Archive_Read()
- scan the archive with the PureZIP_Archive_FindFirst() / PureZIP_Archive_FindNext() functions
- and get the file info (including Filename) with PureZIP_Archive_FileInfo
- do what you have to do with the FileName
- close archive with PureZIP_Archive_Close()
;) yes, actually I use this method. Thank you
PB 6.21 beta, PureVision User
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes :
- New parameter IncludingPath.l for function PureZIP_FindFile()
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
zikitrake
Addict
Addict
Posts: 868
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

gnozal wrote:Update

Changes :
- New parameter IncludingPath.l for function PureZIP_FindFile()
It Works fine. Thank you
PB 6.21 beta, PureVision User
webbmeister
User
User
Posts: 62
Joined: Thu Mar 16, 2006 5:20 pm
Location: Sheffield, UK

Post by webbmeister »

Can anyone supply sample usage to Zip a single file for use with Version 4 Beta 7 ?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

webbmeister wrote:Can anyone supply sample usage to Zip a single file for use with Version 4 Beta 7 ?
Example with DLL : http://www.purebasic.fr/english/viewtopic.php?t=20370 (see Num3 PB_ZIP post)
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 »

That link is a little hard to follow. I have downloaded "purezip.zip" and expanded that into my purebasicbeta program folder. Could someone give me some code to try in v4b7 to zip say c:\test.txt to c:\test.zip.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

webbmeister wrote:That link is a little hard to follow. I have downloaded "purezip.zip" and expanded that into my purebasicbeta program folder. Could someone give me some code to try in v4b7 to zip say c:\test.txt to c:\test.zip.
Maybe the best is to go to Num3's site http://io-soft.planetaclix.pt/software.htm and download his Zlib Procedures http://io-soft.planetaclix.pt/files/Zlib_Procedures.zip
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:
webbmeister wrote:That link is a little hard to follow. I have downloaded "purezip.zip" and expanded that into my purebasicbeta program folder. Could someone give me some code to try in v4b7 to zip say c:\test.txt to c:\test.zip.
Maybe the best is to go to Num3's site http://io-soft.planetaclix.pt/software.htm and download his Zlib Procedures http://io-soft.planetaclix.pt/files/Zlib_Procedures.zip
Maybe it's me been a bit slow, but can't seem to find any usage docs on the website or in the zip file. Maybe some kind soul could provide an example?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

webbmeister wrote:
gnozal wrote:
webbmeister wrote:That link is a little hard to follow. I have downloaded "purezip.zip" and expanded that into my purebasicbeta program folder. Could someone give me some code to try in v4b7 to zip say c:\test.txt to c:\test.zip.
Maybe the best is to go to Num3's site http://io-soft.planetaclix.pt/software.htm and download his Zlib Procedures http://io-soft.planetaclix.pt/files/Zlib_Procedures.zip
Maybe it's me been a bit slow, but can't seem to find any usage docs on the website or in the zip file. Maybe some kind soul could provide an example?
From Zlib.pb in Zlib_Procedures.zip :

Code: Select all

  If ZIP_Lib_Init()
    
    
    ;****  Create Zip File **********
    
    file.s=SaveFileRequester("Select a Zip Filename to save","*.zip","*.zip",1)
    
    If file
      add_file.s=OpenFileRequester("Select File to Add","*.*","*.*",1)
      
      If add_file
        
        Handle.l=ZIP_FileCreate(file,#APPEND_STATUS_CREATE)
        
        If Handle
          
          If ZIP_FileAdd(Handle,add_file,GetFilePart(add_file))
            
            Debug "File Added to Archive..."
            
          EndIf
          ZIP_FileClose(Handle)
          
        EndIf
        
      EndIf
      
      
    EndIf
    
    ; **** Extract Zip file **********
    
    file.s=OpenFileRequester("Select a Zip","*.zip","*.zip",1)
    
    If file
      
      myFileinfo.unz_file_info
      
      count.l=ZIP_FileCount(file)
      Debug "This zip has " + Str(count) + " itens"
      
      out_path.s=PathRequester("Extracto to:" ,"c:\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()
  EndIf
  End
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 »

Code: Select all

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
Found the zip.pb example at last.
Using zip.pb (Num 3) on PB4B7 i get the following error message when I try to compile.....

[COMPILER] Line 34: 'Structure' or 'Interface' already declared: tm_date


any ideas?
Post Reply