Resource Directory ?

Hi,

I want to know is what does the ResourceDirectory, DocumentsDirectory folders when the application is compiled.
Where that folders will be when the application will be on the phone and installed ?

Because I want to read json file in the same place of my main.lua but it doesn’t work, he said, need to use ResourceDirectory but there is nowhere where, corona explain what is this folder when the app is compiled, installed, on the phone.

Sorry my english :slight_smile: [import]uid: 157253 topic_id: 29657 reply_id: 329657[/import]

The resource and documents directories aren’t places you’d place files pre-compile but rather once the app is installed.

You can see the folders in the Corona sandbox or read about them in our docs.

For the json file, are you downloading it? [import]uid: 52491 topic_id: 29657 reply_id: 119038[/import]

For the json file, is just read, not downloading. (it’s a json file to set up the tiles maps)

But, the files in ressources and directory aren’t available by the phone user ?

(for the docs of corona sandbox, I don’t found them) [import]uid: 157253 topic_id: 29657 reply_id: 119043[/import]

There are four folders your app can access within it’s Sandbox.

system.ResourceDirectory – this is the folder that your main.lua lives in. It’s inside your app bundle and it is READ ONLY. If you ship a JSON file with your app to say hold configuration data, you can access it using this directory. However if it’s something you need to write too, you need to have your app copy that data to…

system.DocumentsDirectory – This is a read/write folder where your app should save settings information, databases, etc. Things in this folder will automatically be backed up to iCloud, so Apple doesn’t let you store any thing here that is downloadable from the Internet. Those have to be stored in the …

system.CachesDirectory – Doing an RSS app? Your feeds need to go here. Downloading supplemental levels for your game? Put them here. These files will hang around until the user starts running out of space in which case the can be purged. They will not be backed up to iCloud. For Android, this is the same as the …

system.TemporaryDirectory – These files can be deleted at the system’s will. You cannot assume they will survive the next time the app re-launches.

Hope this helps. [import]uid: 19626 topic_id: 29657 reply_id: 119058[/import]

Thank for that help,

For exemple, for my game, I want to load “level” via a json file, so I need to use system.ResourceDirectory,
but I can’t make subfolders in it ?
I can’t load my json file in subfolders ?

main folder (with main.lua) // resources // levels // level1 // level1.json

For example ? [import]uid: 157253 topic_id: 29657 reply_id: 119083[/import]

yea, just put the subfolder name as part of the filename:

[code]
local path = system.pathForFile(“levels/level1/level.json”, system.ResourcesDirectory)

local fh, errStr = io.open( path, “r” )

[/code] [import]uid: 19626 topic_id: 29657 reply_id: 119230[/import]