[Resolved] Creating directories programatically in system.DocumentsDirectory?

Hi!

I’m getting a remote server set up so I can download levels from it into the system.DocumentsDirectory. Got that part working fine, but the SVG Level Builder Framework expects the levels and graphics to be separated into separate folders, such as

system.DocumentsDirectory -> assets

Then assets has 3 separate folders, “graphics”,“levels” and “backgrounds”.

I can get everything working in the sandbox file area (Because I create the folders manually)

So…how do I create folders on-the-fly programatically once deployed to my iPad, iPhone etc??? [import]uid: 11636 topic_id: 20970 reply_id: 320970[/import]

Uh oh, I just came across:

http://developer.anscamobile.com/content/file-io

that states “Note: Corona does not support creating subdirectories on the device.”
Am I doomed?? :frowning: [import]uid: 11636 topic_id: 20970 reply_id: 82788[/import]

You cant at the moment.

Cant you use the resource directory (ie root) ? and create your subfolders there? [import]uid: 84637 topic_id: 20970 reply_id: 82792[/import]

Oh that’s right!

So as long as I know my directory structure (It’s not going to change or be dynamic or anything like that) I can just create them in root and then I should be good to go?

FYI I’m downloading level files from my webserver and (hopefully) populate the directories with them.

-Mario [import]uid: 11636 topic_id: 20970 reply_id: 82815[/import]

Exactly yeah. If your downloading them from a server im not sure…

Maybe you could save to resource directory, maybe not. If not then you might have a problem if it requires subfolders.

I’m sure you can edit the svg level editor files to take that requirement out however [import]uid: 84637 topic_id: 20970 reply_id: 82816[/import]

I have this same problem (I’m saving “episodes” that have lots of small level preview images and need to be stored in set of sub-directories under system.DocumentsDirectory).

I already had to resort to downloading all of the supporting files one at a time, since Corona has no archive file support (and doesn’t even have the binary Lua extensions required to write it yourself). And now I have to prefix all of the file names with a fake folder identifier (jamming everything into the top level Documents folder). That’s not pretty and I really don’t want to know what happens when I have 1,000 files in Documents.

I’m not convinced that writing to the Resource directory is a good idea, and in my case, I don’t know the subfolder names ahead of time anyway (it’s one episode per “folder”, downloaded from a web server).

I’m starting to wonder if all of these roadblocks are costing me more energy than Corona is saving me.
[import]uid: 111481 topic_id: 20970 reply_id: 86061[/import]

nb see lua file system (LFS)
http://www.coronalabs.com/blog/2012/05/08/luafilesystem-lfs-tutorial/
[import]uid: 74338 topic_id: 20970 reply_id: 111960[/import]

Yeah I saw that and thought of my old post. Perfect solutions!!! [import]uid: 11636 topic_id: 20970 reply_id: 111996[/import]