How to traverse a subdirectory?

Basically just want to pull a list of files in a code subdirectory (i.e.: projectname/languages). Is there any way to actually do this with LFS? (I just get a message that there’s no file or directory).

[lua]local lfs  = require(“lfs”)

    lfs.chdir( system.pathForFile("", system.ResourceDirectory) )

    local path = lfs.currentdir()…"/languages"

   

    – Load in each file found

    for file in lfs.dir(path) do

       – stuff

    end[/lua]

(Note: I’ve found you have to set lfs.chdir at first; if you try just going with lfs.currentdir() stuff like Corona SDK’s boot up or some document utils (GGData) will change currentdir() to DocumentsDirectory and bust your entire code setup…)

cannot open /Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/CoronaResources.bundle/Contents/Resources/languages/: No such file or directory

(if main.lua is in Resources, /languages/ does exist, and so do lua files within /languages)

Solution:

[lua]local path = system.pathForFile(nil, system.ResourceDirectory)…"/languages"

lfs.chdir(path)[/lua]

If you attempt to fetch a path with “” under the argument, and then attempt chdir(), you will get a soft error from Corona and the currentdir() will be a completely different resources location. So make sure to use ‘nil’!

Solution:

[lua]local path = system.pathForFile(nil, system.ResourceDirectory)…"/languages"

lfs.chdir(path)[/lua]

If you attempt to fetch a path with “” under the argument, and then attempt chdir(), you will get a soft error from Corona and the currentdir() will be a completely different resources location. So make sure to use ‘nil’!