How read directories?

How read directories?

Im doing a app that can change Themes. To do this, I will put all images in a directory and I'd like to read the directory to check if exist. If its positive, display it in a table with the approprieate name.

So, Ive read the documentation API about implicit and explicit file manipulation, but its not clear for me. Can I read the directoy?

Thanks for any help.

...

@bsdrago,
you cannot read the directories per say. But you can work around it if you so want.

you said that you will have themes, where do these themes come from? If you have them all packaged when deployed, then you know the directory structure, but if you are wanting to dynamically download a directory from a webserver or something, then save that folder name in a file as a folder that has been created so you know of them. Almost like create a folder table.

cheers,

?:)

I just thought was strange have this function:

io.type() if the only type know is "file"

Sometimes we have an idea, but we dont realize how it will work!

Thanks for your sugestion. I'll try it. :D

Why don't you do it dynamically using modules?

directories.lua:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local directories = {
        {--start of first theme
 
                images = {
 
                     {image="image1.png" width= "40", height="40"},
                     {image="image2.png" width= "40", height="40"},
                     {image="image3.png" width= "40", height="40"},
 
                },
 
         },
 
         {--start of second theme
 
                images = {
 
                     {image="image1.png" width= "40", height="40"},
                     {image="image2.png" width= "40", height="40"},
                     {image="image3.png" width= "40", height="40"},
 
                },
 
         },
                       
}
 
return directories
views:1318 update:2011/10/5 8:48:05
corona forums © 2003-2011