Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Problem with line "for file in lfs.dir(path) do" in project exported — Gideros Forum

Problem with line "for file in lfs.dir(path) do" in project exported

anneMurielleanneMurielle Member
edited January 2014 in General questions
Hi,

My project work without error in Gideros but when I export it and try to run it with Eclipse, the following line "for file in lfs.dir(path) do" return me this error:

cannot open images/folder1/folder2/folder3: No such file or directory

In this for loop, every images of the folder "path" are explored and the corresponding images are created and added to the application.

I've check all the files and folders and they exist.... any idea of what could be the problem ?

Thanks a lot for your help.

Likes: tuanleanh

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • Hello @anneMurielle ;)
    1) when you say you run app in eclipse, you mean on device or simulator? Because simulator has so many problems, you can basically deem it unsupported and should better test on device.
    2) I assume you want to iterate through resources directory, and it might be that relative directory changes somehow, if you try to iterate through path "./" does it have the files you have added to gideros project on the first level?
  • Hello @ar2rsawseen

    1) I mean run it on simulator. I've just install it now on real device and it failed at the same function :(

    2) for this point I'm not sure I understand it correctly. The images are in 3 sub folders with same structure on Gideros and on the disk (ie: "images/games/dessUp"), do I need to put the images on the first level (at the root of the Gideros project or in only one folder ??

    Thanks,
    Anne-Murielle
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    what I meant was, try iterating through "./" on android and see what kind of folders/files are there, if there is a "images" folder, proceed further and check "images", etc, etc, etc

    to see what i the first iteration where it can't find anything
    require"lfs"
     
    function listdir (path)
    	for file in lfs.dir(path) do
    		if file ~= "." and file ~= ".." then
    			local f = path..'/'..file
    			print (f)
    		end
    	end
    end
     
    listdir (".")
  • Hello ar2rsawseen,

    We have the same problem.
    In Gideros |R| and "./" shows the same and correct content, but when I export APK... |R| throws an error - "cannot open |R|: No such file or directory" - and "./" shows like something: persdata, preload, sdcard, persist, storage, ef, config, cache, sbin, res, mnt, system, sys. Apparently the Android's root.
  • wow, ok, noted, will add it to the tracker, seems that on Android lfs plugin does not work through Gideros virtual file system ;)
  • tuanleanhtuanleanh Member
    edited May 2014
    Hi all, I'm stucking at this problem. Everything works well on iOS and Gideros Player but there always has errors when getting the list of files of a folder on Android. It's a nightmare to change all the code #-o
  • gt1993gt1993 Member

    What is the status of this issue?

    "...wow, ok, noted, will add it to the tracker, seems that on Android lfs plugin does not work through Gideros virtual file system..."
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2014
    The issue listed as a high priority in the tracker, but for now we failed to find a proper solution. Problem is, that while in Gideros player it works as expected as those are real files loaded to Gideros Player
    But, when on Android platform, there no more files there in the |R|, its only a single .apk file (You still should be able access documents directory as expected), on the contrary to IOS, where all the contents get extracted to create app folder.

    So for now this issue is due to Android system, and if we will find a plausible solution, I will let you know.

    For now, the only workaround seems to be, to copy the files to document directory.
    It's not a plausible solution, and not even recommended, but still might help in some cases.
    You can find example of the copy functions, here:
    http://docs.giderosmobile.com/reference/plugin/sqlite3#sqlite3
Sign In or Register to comment.