Hi Pedja,
if you are just interested in the files, and not in empty directories,
and if you wont have millions of files in the tree, so memory
considerations are not important, I would suggest to store the tree as
simple "flat" property list with the filenames as keys and the
corresponding path as values, like
tree = [\
"Untitled 1.txt": "rootFolder\data\folder1\About",\
"Untitled 1.jpg": "rootFolder\data\folder1\images"\
...
]
This causes a lot redundancy, but I think it provides the fastest way of
finding a location.
To minimize redundancy (and therefor memory usage), you could store the
tree in a recursive property list that looks like
aFolder =\
[\
"name": "aName",\
"files": [],\
"subfolders":[]\
]
for example
"rootFolder\data"
"rootFolder\data\folder1"
"rootFolder\data\folder1\images"
"rootFolder\data\folder1\images\Untitled 1.jpg"
"rootFolder\data\folder1\images\Untitled 2.jpg"
"rootFolder\Data2"
"rootFolder\Data2\Text"
"rootFolder\Data2\Text\Untitled 1.txt"
would correspond to
tree =
[
"name": "rootFolder",
"files": [],
"subfolders":
[
[
"name": "data",
"files": [],
"subfolders":
[
[
"name": "folder1",
"files": [],
"subfolders":
[
[
"name": "images",
"files": ["Untitled 1.jpg","Untitled 2.jpg"],
"subfolders": []
]
]
]
]
],
[
"name": "Data2",
"files": [],
"subfolders":
[
[
"name": "Text",
"files": ["Untitled 1.txt"],
"subfolders": []
]
]
]
]
]
But I don't know of any fast way of retrieving the location of a given
file.
Valentin
----- Original Message -----
From: "Pedja" <[EMAIL PROTECTED]>
To: "'Lingo programming discussion list'"
<[EMAIL PROTECTED]>
Sent: Tuesday, December 14, 2004 1:07 AM
Subject: <lingo-l> Multidimensional list from tree structure
> Hi guys...need help on this one..I am totally brain dead
>
> I have a tree structure (as text) that looks like some sort of folder
> listing that I need to use as a navigation method.
>
> Here is a dummy example:
>
> "rootFolder"
> "rootFolder\data"
> "rootFolder\data\folder1"
> "rootFolder\data\folder1\About"
> "rootFolder\data\folder1\About\Untitled 1.txt"
> "rootFolder\data\folder1\images"
> "rootFolder\data\folder1\images\Untitled 1.jpg"
> "rootFolder\data\folder1\images\Untitled 2.jpg"
> "rootFolder\data\folder1\images\Untitled 3.jpg"
> "rootFolder\data\folder1\media"
> "rootFolder\data\folder1\media\Untitled 1.mov"
> "rootFolder\data\folder1\media\Untitled 2.mov"
> "rootFolder\data\folder1\text"
> "rootFolder\data\folder1\text\Untitled 1.txt"
> "rootFolder\Data2"
> "rootFolder\Data2\Text"
> "rootFolder\Data2\Text\Untitled 1.txt"
>
> I want to get this bastard in some sort of multidimensional property
> list (in runtime) so I can access the locations quickly...I've tried
> some recursive approach but my brain simply refuses to work (must be
> lack of beer!)
>
> Any suggestions
>
> Cheers
>
> Pedja
>
>
> [To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]).
Lingo-L is for learning and helping with programming Lingo. Thanks!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]