B4J Question [XUI2D] What is the X2_Clean.jar doing

Gunther

Active Member
Licensed User
Longtime User
Hi,

Within the example package a jar is delivered: X2_Clean.jar
Before it was: X2_CleanAndUpdateObjectTypes.jar

What is the purpose of this JARs?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Good questions :)

This is the code:
B4X:
Sub AppStart (Args() As String)
   For Each s As String In Array("C:\Users\H\Documents\AddLib", "C:\Users\H\Documents\AddLib\b4j", "C:\Users\H\Documents\AddLib\B4i")
       File.Copy("", "X2 Source Code\X2.b4xlib", s, "X2.b4xlib")
   Next
   SearchForObjectsFolders(File.DirApp)
End Sub

Private Sub SearchForObjectsFolders (Parent As String)
   For Each f As String In File.ListFiles(Parent)
       If File.IsDirectory(Parent, f) Then
           Dim folder As String = File.Combine(Parent, f)
           If f.ToLowerCase = "objects" Or f.ToLowerCase = "autobackups" Then
               RecursiveDelete(folder)
           Else If f.ToLowerCase = "files" Then
               HandleFilesFolder(folder)
           Else
               SearchForObjectsFolders(folder)
           End If
       End If
   Next
End Sub

Private Sub HandleFilesFolder (Folder As String)
   For Each f As String In File.ListFiles(Folder)
       If File.Size(Folder, f) > 2 And Regex.IsMatch(".*\.b.?l", f) = False And f <> "objecttypes.json" Then
           File.WriteString(Folder, f, "")
       End If
   Next
End Sub

Private Sub RecursiveDelete(folder As String)
   For Each f As String In File.ListFiles(folder)
       If File.IsDirectory(folder, f) Then
           RecursiveDelete(File.Combine(folder, f))
       End If
       File.Delete(folder, f)
   Next
End Sub

It is a utility jar that does several things. You are not expected to use it. It just gets packed together with all the projects because it is there.

1. Copies the updated X2.b4xlib to the three additional libraries folders (one day it will not be needed...)
2. Searches for the Objects folders and AutoBackup folders in the 20 projects and deletes them.
3. Empties all the assets files except of the layout files (the only files that are not shared).

X2_CleanAndUpdateObjectTypes did similar things and also copied objecttypes.json to the various projects. This is no longer needed because the file is now included in the b4xlib.
 
Upvote 0
Top