Referring to THIS post I though how nice I can get and open zips without a lib BUT.
I modified ZipToMap and found it does not always return the Folders. Some zips it does, others it doesn't. Since the purpose of the code is to return file contents it is not an issue for ZipToMap but I was trying to build a tree. And the folders are sometimes missing. Specifically I saw the problem in this file: https://dl.google.com/android/repository/commandlinetools-win-9123335_latest.zip.
Has folders:
No Folders:
(Interestingly I even found on one zip with only two files and no subs it ADDED a root "/" entry. But perhaps that is because the two files were both themselves zip files.)
Here is the modified code I used:
I modified ZipToMap and found it does not always return the Folders. Some zips it does, others it doesn't. Since the purpose of the code is to return file contents it is not an issue for ZipToMap but I was trying to build a tree. And the folders are sometimes missing. Specifically I saw the problem in this file: https://dl.google.com/android/repository/commandlinetools-win-9123335_latest.zip.
Has folders:
No Folders:
(Interestingly I even found on one zip with only two files and no subs it ADDED a root "/" entry. But perhaps that is because the two files were both themselves zip files.)
Here is the modified code I used:
B4X:
Private Sub ZipToMap (ZipPath As String, Fldr As String) As Map
'Private Sub ZipToMap (ZipPath As String) As Map
Dim result As Map
result.Initialize
Dim ZipFile As JavaObject
ZipFile.InitializeNewInstance("java.util.zip.ZipFile", Array(ZipPath))
Dim enumeration As JavaObject = ZipFile.RunMethod("entries", Null)
Do While enumeration.RunMethod("hasMoreElements", Null).As(Boolean)
Dim ZipEntry As JavaObject = enumeration.RunMethod("nextElement", Null)
Dim Name As String = ZipEntry.RunMethod("getName", Null)
result.Put(Name, IIf(Name.EndsWith("/"), "Folder", "File"))
Loop
ZipFile.RunMethod("close", Null)
Return result
End Sub