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 »

Kiffi wrote:
gnozal wrote:Could you try it ?
sorry, same behaviour as before: PureZIP_ExtractFiles returns #Null and the
uncompressed filesize is negative.

Greetings ... Kiffi
Well, it seems to be a LONG -> QUAD conversion problem ...

Code: Select all

Structure test
  TESTL.l 
  TESTQ.q 
EndStructure
t.test\TESTL = 2500000000
t.test\TESTQ = 2500000000
Size.q = t\TESTL
Debug Size ; -1794967296 !!!
Size = t\TESTQ
Debug Size ; 2500000000
it works like this :

Code: Select all

Size.q = t\TESTL & $FFFFFFFF
BETA lib updated, please try again (sorry).
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
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

> BETA lib updated

well done, gnozal! Now i can extract the file. And the progress value in the
Callback works also. :D

Unfortunately the FileInfo i receive with PureZIP_Archive_FileInfo() contains a
negative uncompressed filesize. But i'am sure, that you will get it. ;-)

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

Post by zikitrake »

:? is this a bug... or I'm a bigbug???:

I've a file (TEST-TIME.TXT) with modified date: 23/06/2006 20:53:11

When I view modified date in TEST-TIME.TXT in the zipped file, it lost a second.

Code: Select all

myFileinfo.PureZIP_FileInfo

MyZIP.s = "C:\test.zip"
MyFilesToZIP.s = "C:\TEST\test-time.txt"

Debug PureZIP_AddFiles(MyZIP, MyFilesToZIP, #PureZIP_StorePathAbsolute, #PureZIP_Recursive)
It only occurs with some hours, any help?

Really thank you, Gnozal!

... and sorry for my bad (fatal) english
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 »

Kiffi wrote:> BETA lib updated

well done, gnozal! Now i can extract the file. And the progress value in the
Callback works also. :D

Unfortunately the FileInfo i receive with PureZIP_Archive_FileInfo() contains a
negative uncompressed filesize. But i'am sure, that you will get it. ;-)

Greetings ... Kiffi
The FileInfo structure has longs, as it is a ZLIB based structure. You will have to do a correction like : FileSize.q = FileInfo\unCompressedSize & $FFFFFFFF. I will add this in the manual.
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 wrote:I've a file (TEST-TIME.TXT) with modified date: 23/06/2006 20:53:11

It only occurs with some hours, any help?
I am afraid not.
I only fill a structure for ZLIB :

Code: Select all

Procedure FileTimeToDate(*FT.FILETIME)
  FileTimeToLocalFileTime_(*FT.FILETIME,FT2.FILETIME)
  FileTimeToSystemTime_(FT2,st.SYSTEMTIME)
  ProcedureReturn Date(st\wYear,st\wMonth,st\wDay,st\wHour,st\wMinute,st\wSecond)
EndProcedure
Procedure LIB_GetFileDate(File.s)
  result=0
  Handle=CreateFile_(@File,#GENERIC_READ,#FILE_SHARE_READ|#FILE_SHARE_WRITE,0,#OPEN_EXISTING,#FILE_ATTRIBUTE_NORMAL,0)
  If Handle<>#INVALID_HANDLE_VALUE
    GetFileTime_(Handle,0,0,FT.FILETIME)
    result=FileTimeToDate(FT)
    CloseHandle_(Handle)
  EndIf
  ProcedureReturn result
EndProcedure

        ; ////// Store file date into zfi.zip_file_info
        FileDate = LIB_GetFileDate(FileName)
        zfi\tm_zip\tm_sec = Val(FormatDate("%ss", FileDate))
        zfi\tm_zip\tm_min = Val(FormatDate("%ii", FileDate))
        zfi\tm_zip\tm_hour = Val(FormatDate("%hh", FileDate))
        zfi\tm_zip\tm_mday = Val(FormatDate("%dd", FileDate))
        zfi\tm_zip\tm_mon = Val(FormatDate("%mm", FileDate)) - 1
        zfi\tm_zip\tm_year = Val(FormatDate("%yyyy", FileDate))
        ; //////
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.00 version only)

Changes :
- PureZIP now supports files up to 4 GB size.

Note
ZLIB can handle files up to 4 Gbytes, but PB longs are signed [0 - 2 Gbytes]...
So if you expect PureZIP_FileInfo\CompressedSize > 2 Gbytes or PureZIP_FileInfo\unCompressedSize > 2 Gbytes,
use quads and convert signed to unsigned !
Example : Size.q = FileInfo\unCompressedSize & $FFFFFFFF

Download : http://people.freenet.de/gnozal/PureZIP_.zip
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

If I try to append a zip to my executable, the executable is killed and no longer works (zip is ok). I don't know, what's the error.

Code: Select all

If PureZIP_Archive_Create(OutputDir$+Exe$, #APPEND_STATUS_CREATEAFTER)
  If ExamineDirectory(0, Dir$, "*.*")  
    While NextDirectoryEntry(0)
      If DirectoryEntryType(0) = #PB_DirectoryEntry_File
        PureZIP_Archive_Compress(Dir$+"\"+DirectoryEntryName(0), #False)            
      EndIf
    Wend
    FinishDirectory(0)
  EndIf
  PureZIP_Archive_Close()
EndIf
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Thorsten1867 wrote:If I try to append a zip to my executable, the executable is killed and no longer works (zip is ok). I don't know, what's the error.
Yes, I noticed. I don't know what the problem is with #APPEND_STATUS_CREATEAFTER.
What I do : I simply copy the final ZIP at the end of the executable and it works.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

gnozal wrote:What I do : I simply copy the final ZIP at the end of the executable and it works.
That's the code I need. How can I do this? I've no idea how two join to files.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

gnozal wrote:Changes :
- PureZIP now supports files up to 4 GB size.
Wonderful, now it works! :D

Three cheers for gnozal!

Thanks & Greetings ... Kiffi
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Thorsten1867 wrote:
gnozal wrote:What I do : I simply copy the final ZIP at the end of the executable and it works.
That's the code I need. How can I do this? I've no idea how two join to files.

Code: Select all

Procedure LinkToExe(ExeFile.s, ZipFile.s)
  Protected File.l, Pack.l, Size.l, Mem.l
  File = OpenFile(#PB_Any, ExeFile)
  If File
    Pack = ReadFile(#PB_Any, ZipFile)
    Size = Lof(Pack)
    Mem = AllocateMemory(Size)
    If Mem
      ReadData(Pack, Mem, Size)
      CloseFile(Pack)
      FileSeek(File, Lof(File))
      WriteData(File, Mem, Size)
      CloseFile(File)
      FreeMemory(Mem)
      ProcedureReturn #True
    EndIf
  EndIf
  ProcedureReturn #False
EndProcedure
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Thanks for this lib =)
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Gnozal, PureZIP opens a SFX module only if the data is appended at the end? I ask you this because was trying to find a solution to have inside a settings file too... How does your library installer work? As i've seen, it doesn't create any temporary 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 »

Inf0Byt3 wrote:As i've seen, it doesn't create any temporary files :? .
I add the installer information in a file in the ZIP (in my installer it's "File_Id.Diz"). This file is not extracted but the installer reads its content with PureZIP_Archive_ExtractMem().
Download http://people.freenet.de/gnozal/PureLVSORT_.zip and open PureLVSORT-Installer.exe in WInRAR or any other archiver : you will see the "File_Id.Diz" at the root of the archive.
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 »

Oh... I see... Thanks for the tip :D... I had a hunch about this but I was unsure about it :D.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Post Reply