B4A Library [Lib] Archiver

By courtesy of Djembefola, this library is released as freeware for the benefit of the community. You should send him a big "thank you".

This library provides a basic support for Zip, Tar and Gzip archives (including TarGz). It can compress/uncompress synchronously or asynchronously (one task in the background at a time). This lib doesn't support encryption (but you can use it with encrypted files).

Its use is fairly simple. Examples:
B4X:
Dim Arc As Archiver

Arc.Gzip(File.DirRootExternal, "test2.tar", File.DirRootExternal)
Arc.UnGzip(File.DirRootExternal, "test2.tar.gz", File.DirRootExternal & "/testTARgz2")
Arc.AsyncGzip(File.DirRootExternal & "/media/image", "test.jpg", File.DirRootExternal, "Arc")

Dim m As Map
Try
   m = Arc.ListZipEntries(File.DirRootExternal & "/media/image/Icones", "android-icons.zip")
   For i = 0 To m.Size - 1
      Dim Info(3) As Long
      Info = m.GetValueAt(i)
      Log(m.GetKeyAt(i))
      Log("   Uncompressed size = " & Info(0))
      Log("   Compressed size = " & Info(1))
      Log("   CRC = " & Info(2))
   Next
Catch
   Log(LastException.Message)
End Try

This library is provided as-is and will not be extended to other formats. It uses the JTar library.

Don't forget to credit the authors if you include it in your application:
Frédéric Leneuf-Magaud & Kamran Zafar

v1.11:
I improved the synchronization of asynchronous operations (Async orders can be enqueued now);
The event declarations appear now with Space+Tab in the IDE.*

There's an improved version of this library for Zip files in my ProBundle that supports encryption and decryption.
 

Attachments

  • Archiver v1.11.zip
    26.4 KB · Views: 3,746
Last edited:

wonder

Expert
Licensed User
Longtime User
Thanks, this really helps!! :) I'll try to take it from here.

EDIT: I fixed the error I was getting.
 
Last edited:

Marcio Almeida

Member
Licensed User
Longtime User
Hi guys! I'm having difficulty unzip a 13.7mb file. Below the file link and code I currently use:

Code:
arc.UnZip(fileDir, fileZipNameFotos, fileDirFotos, "")
or arc.AsyncUnZip(fileDir, fileZipNameFotos, fileDirFotos, "UnZipFotos")

Link:
http://www.wmesistemas.com.br/temp/fotosprodutos.zip


The strange thing is that with smaller files this is working properly.

Thanks a lot!
 

aidymp

Well-Known Member
Licensed User
Longtime User
Hi guys! I'm having difficulty unzip a 13.7mb file. Below the file link and code I currently use:

Code:
arc.UnZip(fileDir, fileZipNameFotos, fileDirFotos, "")
or arc.AsyncUnZip(fileDir, fileZipNameFotos, fileDirFotos, "UnZipFotos")

Link:
http://www.wmesistemas.com.br/temp/fotosprodutos.zip


The strange thing is that with smaller files this is working properly.

Thanks a lot!

A few years ago I had terrible problems with zips, at the time there was a paid library ArchiverPlusZip it worked straight away. It is part of the excellent ProBundle . And
It is now FREE and can be found here. https://www.b4x.com/android/forum/threads/probundle-chargeable.58754/#content

Hope that helps.
 

b4x-de

Active Member
Licensed User
Longtime User
Hi,

in version 1.11 of that library I'm experiencing the problem that arc.UnZip() and arc.AsyncUnZip() behave differently regarding directories inside the zip archive.

While arc.UnZip() is unzipping directories recursively arc.AsyncUnZip() does not. Does someone else experiencing the same problem?

Thanks,
Thomas
 

Informatix

Expert
Licensed User
Longtime User
Hi,

in version 1.11 of that library I'm experiencing the problem that arc.UnZip() and arc.AsyncUnZip() behave differently regarding directories inside the zip archive.

While arc.UnZip() is unzipping directories recursively arc.AsyncUnZip() does not. Does someone else experiencing the same problem?

Thanks,
Thomas
Since AsyncUnzip calls internally Unzip, I can't see how the result could be different. If it's really the case, then the problem lies in the part of the code that I cannot change (the Android java.util.zip package).
 

JohnC

Expert
Licensed User
Longtime User

DonManfred

Expert
Licensed User
Longtime User
In the below post, the user says that this Archive Lib crashes on Android 8.0+, is this true?
i tried the example using targetsdk 26 on my Android 9 device. It does not crash.
i tried the example using targetsdk 28 on my Android 9 device. It does not crash.

Edit to add: I used ArchiverPlus 1.12
 

JohnC

Expert
Licensed User
Longtime User
i tried the example using targetsdk 26 on my Android 9 device. It does not crash.
i tried the example using targetsdk 28 on my Android 9 device. It does not crash.

Edit to add: I used ArchiverPlus 1.12
Thanks for the quick reply - I'll give it a try!
 

JohnC

Expert
Licensed User
Longtime User

JohnC

Expert
Licensed User
Longtime User
I am getting another weird issue with this lib which seems to suggest that the "Wait for" event is triggered before your zip method completes:

 

Informatix

Expert
Licensed User
Longtime User
I am getting another weird issue with this lib which seems to suggest that the "Wait for" event is triggered before your zip method completes:

Wrong thread.
 
Top