iOS Question [SOLVED?] Bug in File.ListFiles in Release mode

JackKirk

Well-Known Member
Licensed User
Longtime User
I feel a bit like chicken little - running around the barnyard screaming "the sky is falling".

This has to be a bug - or at least better be for my own sanity.

If you run this code in debug mode:
B4X:
#Region  Project Attributes
    #ApplicationLabel: Bug
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 7
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

End Sub

Private Sub Application_Start (Nav As NavigationController)
    Dim rl As ReleaseLogger
    rl.Initialize("192.168.1.6", 54323)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)

    Private wrk_files As List
    Private wrk_str As String
    Private wrk_ptr As Int

    'Get names of files in assets directory
    wrk_files = File.ListFiles(File.DirAssets)

    'For all files...
    For wrk_ptr = 0 To wrk_files.Size - 1

        'Get a file name
        wrk_str = wrk_files.Get(wrk_ptr)
'Log(1)
        'If not another directory...
        If Not(File.IsDirectory(File.DirAssets, wrk_str)) Then
'Log(2)     
            Log(wrk_str)
     
        End If
     
    Next

End Sub

The IDE log says:
Application_Start
Ignoring release logger in debug mode.
Application_Active
_assets_map
beep.mp3
radiobutton_off.png
radiobutton_on.png
wmm2010.cof
wmm2015.cof

Which is what you would expect, given the files in the projects assets.

If you delete the installed Bug app from the phone, uncomment the 2 Log statements in Page1_resize and then run it in release mode it dies a nasty death at the statement:

If Not(File.IsDirectory(File.DirAssets, wrk_str)) Then

The B4iLogger saying:

Additional information - if you reconfigure the last couple of lines as follows:
B4X:
    'For all files...
    For wrk_ptr = 0 To wrk_files.Size - 1

        'Get a file name
        wrk_str = wrk_files.Get(wrk_ptr)
'Log(1)
        'If not another directory...
        'If Not(File.IsDirectory(File.DirAssets, wrk_str)) Then
'Log(2)     
            Log(wrk_str)
     
        'End If
     
    Next

And run it again in release mode, the B4iLogger says:

Which is decidedly not what is in the assets of the project.

Please tell me this is a bug...
 

Attachments

  • Bug.zip
    444.3 KB · Views: 205
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that you should post bug reports in the bugs forum.
There is no bug here. File.DirAssets is a special folder. In debug mode it is stored as a regular folder (to allow quick deployments).

You shouldn't use File.ListFiles with the assets folder. I will add a note about it in the documentation. Note that it is also true in B4J and B4A.
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
You shouldn't use File.ListFiles with the assets folder. I will add a note about it in the documentation. Note that it is also true in B4J and B4A.

This came about because of my porting a B4A app to B4I - it has been working fine in the B4A app for some months.

I grant that it could be considered unnecessary to use ListFiles on the assets seeing as how the assets are static at compile time - however this means I have to remember to update the alternative everytime I add something to the assets and recompile.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…