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 »

AL90 wrote:A ReadOnly file packed and with PFM extracted, and the flag is hold.
If I pack it with pureZip the flag will lost. So are flags readable but not
writeable in archive. Thats is what I mean.
Thanks, I understand now.
The only file info I get is in the PureZIP_FileInfo structure.
Maybe the file attributes are in the internal_fa/external_fa members (the ZLIB doc isn't very good ...) ?

Code: Select all

internal_fa.l		; internal file attributes
external_fa.l		; external file attributes
I don't have much time, so could you please test this ?

If it works, I could use this in PureZIP to recreate the original file attributes after extraction.
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 »

gnozal wrote:If it works, I could use this in PureZIP to recreate the original file attributes after extraction.
I use external_fa.l to recreate the Attributes after extraction in PFM.
I have testet internal_fa.l but I think it has no function (?)
Here a small example from my code how I recreate the Attributes after extraction.

Code: Select all

Procedure.l GetFileAttributesZIP(ZipFile$,File$)
  ZipNr.l=PureZIP_FindFile(ZipFile$, Right(File$,Len(File$)-5), #True)
  PureZIP_GetFileInfo(ZipFile$, ZipNr, @FileInfo.PureZIP_FileInfo)
  x.l=FileInfo\external_fa.l
  ProcedureReturn x
EndProcedure

...
...
...

SetFileAttributes(...)
Is not the best way, but it works good.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

Hello Gnozal,

Is your PureZip library also available as a language-independent DLL?
Anthony Jordan
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

akj wrote:Hello Gnozal,
Is your PureZip library also available as a language-independent DLL?
Currently 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 »

New beta http://freenet-homepage.de/gnozal/PureZIP_BETA.zip

Changes :
- added function PureZIP_AsciiDosUS_To_AsciiWinWestern() usefull for german users ; thanks to String from the german forum
- added file attributes support : PureZIP now stores the packed files attributes in external_fa.l member of PureZIP_FileInfo and restores the attributes after unpacking.

Please test !
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 »

gnozal wrote:Please test !
It doesn't work. Only if I adding following lines.:

Code: Select all

FileAttributes=FileInfo\external_fa.l  ; Flags nach dem entpacken setzen.
SetFileAttributes(File$,FileAttributes)
I have packed a file with 'ReadOnly & Archived-Flags' and I get as result

"----" (No Flags)

with my two lines on top is the result:

"ra--" (ReadOnly and Archived)

so correct only with these two added code-lines on top.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AL90 wrote:It doesn't work.
Seems to works here.
I am using this when I pack the file :
FileInfo\external_fa = GetFileAttributes_(@FileName)
and this after unpacking the file :
SetFileAttributes_(@FileName, FileInfo\external_fa)

Test directory (c:\PureBasic400\Program\ZIP\)

Code: Select all

c:\PureBasic400\Program\ZIP\0.pb	1 538	18/06/07 13:49	----
c:\PureBasic400\Program\ZIP\A.pb	1 538	18/06/07 13:49	-a--
c:\PureBasic400\Program\ZIP\H.pb	1 538	18/06/07 13:49	--h-
c:\PureBasic400\Program\ZIP\R.pb	1 538	18/06/07 13:49	r---
c:\PureBasic400\Program\ZIP\RA.pb	1 538	18/06/07 13:49	ra--
c:\PureBasic400\Program\ZIP\S.pb	1 538	18/06/07 13:49	---s
Test code

Code: Select all

myFileinfo._PureZIP_FileInfo
MyZIP.s = "c:\PureBasic400\Program\ZIP\TestFile.zip" 
If PureZIP_Archive_Create(MyZIP, #APPEND_STATUS_CREATE)
  PureZIP_Archive_Compress("c:\PureBasic400\Program\ZIP\0.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Program\ZIP\A.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Program\ZIP\RA.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Program\ZIP\R.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Program\ZIP\H.pb", #False)
  PureZIP_Archive_Compress("c:\PureBasic400\Program\ZIP\S.pb", #False)
  PureZIP_Archive_Close()
EndIf

If PureZIP_Archive_Read(MyZIP)
  Found = PureZIP_Archive_FindFirst()
  While Found = #UNZ_OK
    Info = PureZIP_Archive_FileInfo(@myFileinfo)  
    Debug "INFO ---"
    Debug myFileinfo\FileName
    Debug myFileinfo\external_fa.l
    PureZIP_Archive_Extract("c:\PureBasic400\Program\ZIP2", #False)
    Found = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf
End
Debug Output

Code: Select all

INFO ---
0.pb
128
INFO ---
A.pb
32
INFO ---
RA.pb
33
INFO ---
R.pb
1
INFO ---
H.pb
2
INFO ---
S.pb
4
Unpacked files (in c:\PureBasic400\Program\ZIP2\)

Code: Select all

c:\PureBasic400\Program\ZIP2\0.pb	1 538	18/06/07 13:49	----
c:\PureBasic400\Program\ZIP2\A.pb	1 538	18/06/07 13:49	-a--
c:\PureBasic400\Program\ZIP2\H.pb	1 538	18/06/07 13:49	--h-
c:\PureBasic400\Program\ZIP2\R.pb	1 538	18/06/07 13:49	r---
c:\PureBasic400\Program\ZIP2\RA.pb	1 538	18/06/07 13:49	ra--
c:\PureBasic400\Program\ZIP2\S.pb	1 538	18/06/07 13:49	---s
So it's ok here !?
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 »

Hello gnozal,

I have test it again and it works now fine. Possibly I have it use bad to my first try. Sorry.
I think I forgot to restart jaPBe after replace the new PureZIP lib.

BTW:
I have now remove all Set/GetFileAttributes from my code and it works also without fine.
Thanks for the good job. :D
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (Both libs)

Changes :

- added function PureZIP_AsciiDosUS_To_AsciiWinWestern() usefull for german users ; thanks to String from the german forum
- added file attributes support : PureZIP now stores the packed files attributes in external_fa.l member of PureZIP_FileInfo and restores the attributes after unpacking.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Post by Sveinung »

Is there a size limit to this lib? I get a lot of errors when files are above 1 Gb :?:

Regards
Sveinung
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Sveinung wrote:Is there a size limit to this lib? I get a lot of errors when files are above 1 Gb :?:
What errors ?
ZLIB has a 2 Gb archive size limit. The PB file functions can handle files up to 2^64 bytes if the filesystem supports it.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Post by Sveinung »

When I create large archives (+- 1 Gb) the archives usealy comes up empty, but the filesize of the archive looks ok. I also get a lot of crc errors whe n making archives with PureZIP_AddFiles(). Lots of files missing to.

Regards
Sveinung
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Sveinung wrote:When I create large archives (+- 1 Gb) the archives usealy comes up empty, but the filesize of the archive looks ok. I also get a lot of crc errors whe n making archives with PureZIP_AddFiles(). Lots of files missing to.
Try working with the PureZIP_Archive_* functions. And check if they are returning any error(s).
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 »

Gnozal, shouldn't Zlib read/write GZip files too? Can you make PureZIP support gzip too or is it too hard?
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, shouldn't Zlib read/write GZip files too? Can you make PureZIP support gzip too or is it too hard?
Yes, with ZLIB you can handle gzip files, but it's another set of functions : have a look at the gz* functions in zlib.h (for PureZIP I only used the zip*/unz* functions).
So it's possible, but it's a whole new set of functions, almost a new library.

Have a look at this thread (german forum) : http://www.purebasic.fr/german/viewtopic.php?t=10088 Maybe it helps ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply