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: 2,780
Last edited:

msali

Member
Licensed User
Just downloaded and used ZipFolder and unzip functions.
Works like a charm so far.
Thanks.
 

bgsoft

Well-Known Member
Licensed User
Hi, thanks for your contribution.

It would be possible to create an archive with password?

Thank You
 

b4auser1

Well-Known Member
Licensed User
Is it possible to unzip files from an archive file located in DirAssets, without preliminary coping it to the DirInternal or DirExternal ?
 

Thuong

Member
Licensed User
Thank
I try ABZipUnzip, but Windows can't read (error when open)
I will try your archiver
 

Thuong

Member
Licensed User
here
arc.ZipFiles(File.DirRootExternal, Array As String("tmpECG.txt"), File.DirRootExternal, "1min.zip", "")
 

Attachments

  • 1min.zip
    5.2 KB · Views: 71

Thuong

Member
Licensed User
Yes, I zip it then send FTP to computer
arc.ZipFiles(File.DirRootExternal, Array As String("tmpECG.txt"), File.DirRootExternal, "1.zip", "")
FTP.UploadFile(File.DirRootExternal, "1.zip", True, "1min.zip")
 

Thuong

Member
Licensed User
zip file is good on android, but when transfer it to computer, it is corrupted
I will check FTP code !, first i send 1min.txt file, It transfer to computer is OK, then send zip is corrupted
 
Last edited:

aidymp

Well-Known Member
Licensed User
Hi, i have a strange problem with this library, down to the progress event . In debug mode my progress meter works! (im using 2 at the moment for a test) standard progressbar and the circleprogress lib (that I am moving too) in release mode I get progressbar1 working - but only if i remove the circleprogress code. In debug mode both work fine! what could be the problem?

B4X:
Sub prog_UnZipProgression(Count As Int, FileName As String)
Log ((Count * 100) / testo) ' - Shows in debug mode - not in release mode!
ProgressBar1.Progress = (Count * 100) / testo ' - Shows in debug mode - AND in release mode!
apm1.Progress = (Count * 100) / testo ' - Shows in debug mode - not in release mode!
End Sub

I also notice that if i try to update a Label with the progress that too only works in debug mode!

Any clues?

Thanks

Aidy
 

Informatix

Expert
Licensed User
Hi, i have a strange problem with this library, down to the progress event . In debug mode my progress meter works! (im using 2 at the moment for a test) standard progressbar and the circleprogress lib (that I am moving too) in release mode I get progressbar1 working - but only if i remove the circleprogress code. In debug mode both work fine! what could be the problem?

B4X:
Sub prog_UnZipProgression(Count As Int, FileName As String)
Log ((Count * 100) / testo) ' - Shows in debug mode - not in release mode!
ProgressBar1.Progress = (Count * 100) / testo ' - Shows in debug mode - AND in release mode!
apm1.Progress = (Count * 100) / testo ' - Shows in debug mode - not in release mode!
End Sub

I also notice that if i try to update a Label with the progress that too only works in debug mode!

Any clues?

Thanks

Aidy
Do you use an Async.... function ?
 

aidymp

Well-Known Member
Licensed User
Do you use an Async.... function ?

Hi yes I call the command with

B4X:
Archiver1.AsyncUnZip(File.DirDefaultExternal , "/Download/Payload", EXTRACTPath , "prog")

the event
B4X:
prog_UnZipProgression(Count As Int, FileName AsString)
is called as

B4X:
ProgressBar1.Progress = (Count * 100) / testo
this line executes - BUT ONLY IF its on its own (in release & debug mode)

if I use
B4X:
apm1.Progress = (Count * 100) / testo
instead that works in DEBUG mode only!

I was hoping to replace the very thin progress bar with this nice large circle, it works fine on the download progress sub! but not in the unzipprogression sub!

this sub has always had problems for me for example using a command like
B4X:
lable1.text = "Unzipping - " & (Count * 100) / testo

also does not work!

is it a bug in the lib or my code?

Thanks

Aidy
 

Informatix

Expert
Licensed User
Hi yes I call the command with

B4X:
Archiver1.AsyncUnZip(File.DirDefaultExternal , "/Download/Payload", EXTRACTPath , "prog")

the event
B4X:
prog_UnZipProgression(Count As Int, FileName AsString)
is called as

B4X:
ProgressBar1.Progress = (Count * 100) / testo
this line executes - BUT ONLY IF its on its own (in release & debug mode)

if I use
B4X:
apm1.Progress = (Count * 100) / testo
instead that works in DEBUG mode only!

I was hoping to replace the very thin progress bar with this nice large circle, it works fine on the download progress sub! but not in the unzipprogression sub!

this sub has always had problems for me for example using a command like
B4X:
lable1.text = "Unzipping - " & (Count * 100) / testo

also does not work!

is it a bug in the lib or my code?

Thanks

Aidy
When you use an asynchronous function (running in another thread), all results in Debug mode cannot be trusted. Use only the Release mode. And please note that all async calls are enqueued (they are run one after the other).
 

aidymp

Well-Known Member
Licensed User
When you use an asynchronous function (running in another thread), all results in Debug mode cannot be trusted. Use only the Release mode. And please note that all async calls are enqueued (they are run one after the other).

Hi thanks for that, I understand but why will progress only work for progressbar1? and not anything else like
B4X:
lable1.text = "Unzipping - " & (Count * 100) / testo

or

B4X:
apm1.Progress = (Count * 100) / testo

it is a real shame that i can only display progress in release mode with progressbar! i will look if i can use a timer and update the circleprogress with the value from progressbar1 and maybe have that hidden!

Thanks

Aidy
 
Top