Hi!
I read current description of system.pathForFile here:
http://docs.coronalabs.com/api/library/system/pathForFile.html
Here is what function system.pathForFile should return:
If the base directory is system.ResourceDirectory and the generated path points to a non-existent file, nil is returned and a warning message is displayed in the Terminal/console.
I know about “Android File Restrictions” but I think that this is not applicable here.
I unit test my code and I found something strange about this function. Test it yourself if you have android device:
-
Create new blank project in Corona SDK simulator.
-
In main.lua file paste this code:
print(“Test started!”);
local path = system.pathForFile( “notExistingFile.txt” )
if path ~= nil then print(“First run : path is “…path…” !”); else print(“First run : path is null!”); end
local path2 = system.pathForFile( “notExistingFile.txt” )
if path2 ~= nil then print(“Second run : path2 is “…path2…” !”); else print(“Second run : path2 is null!”); end
print(“Test ended!”);
Now if you run this code in Simulator, result is as expected:
Copyright © 2009-2013 C o r o n a L a b s I n c .
Version: 3.0.0
Build: 2013.2100
Test started!
WARNING: Cannot create path for resource file ‘notExistingFile.txt’ b/c it does
not exist.First run : path is null!
WARNING: Cannot create path for resource file ‘notExistingFile.txt’ b/c it does
not exist.Second run : path2 is null!
Test ended!
- Generate android app and load it on android device, then run application. Result is strange:
V/Corona (29095): > Class.forName: network.LuaLoader
V/Corona (29095): < Class.forName: network.LuaLoader
V/Corona (29095): Loading via reflection: network.LuaLoader
I/Corona (29095): Test started!
I/Corona (29095): First run : path is null!
I/Corona (29095): Second run : path2 is /data/data/com.gmail.mymail.ABC/files/
coronaResources/notExistingFile.txt !
I/Corona (29095): Test ended!
- If I leave app and return to app, result is even worse:
V/Corona (29095): > Class.forName: network.LuaLoader
V/Corona (29095): < Class.forName: network.LuaLoader
V/Corona (29095): Loading via reflection: network.LuaLoader
I/Corona (29095): Test started!
I/Corona (29095): First run : path is /data/data/com.gmail.mymail.ABC/files/co
ronaResources/notExistingFile.txt !
I/Corona (29095): Second run : path2 is /data/data/com.gmail.mymail.ABC/files/
coronaResources/notExistingFile.txt !
I/Corona (29095): Test ended!
My point is that this behavior is not as described in first quote.
My telephone with android is HTC One. Android version: 4.2.2.
I would like to ask for two things:
-
Can anyone test code which I posted above with other Android devices? Please attach debug log which can be captured on PC with command: adb.exe logcat Corona:v *:s
-
If problem is confirmed what should I do then? Rise bug report? What to do if this problem is only with my device?
Thank you in advance for your help.
Btw: Limited quotes number is … not very smart idea.
Regards,
Ikeban