We're going to assume that you have more than two levels in your tree.
Because of this, you are going to have to write a recursive macro.
First, your HDF is going to look something like the following:
Files.0.Name = Desktop
Files.0.Type = dir
Files.0.Sub.0.Name = Bookmarks.html
Files.0.Sub.0.Type = file
Files.0.Sub.1.Name = History.txt
Files.0.Sub.1.Type = file
Files.0.Sub.2.Name = Resume.doc
Files.0.Sub.2.Type = file
Files.1.Name = .cshrc
Files.1.Type = file
Files.2.Name = .login
Files.2.Type = file
Files.2.Name = Mail
Files.2.Type = dir
Files.2.Sub.0.Name = inbox
Files.2.Sub.0.Type = file
Files.2.Sub.1.Name = received
Files.2.Sub.1.Type = file
Files.2.Sub.2.Name = sent
Files.2.Sub.2.Type = file
Files.2.Sub.2.Name = postponed
Files.2.Sub.2.Type = file
Ok, first the simple version:
<?cs def:display_files(files) ?>
<ul>
<?cs each:file = files ?>
<li><?cs var:file.Name ?></li>
<?cs if:file.Sub.0.Name ?>
<?cs call:display_files(file.Sub) ?>
<?cs /if ?>
<?cs /each ?>
</ul>
<?cs /def ?>
<?cs call:display_files(Files) ?>
This version relies on HTML to format your list. Notice how we
check both the existance of the sub element before we
recurse, because otherwise we'll get an extra ul pair, which in most
browsers will cause extra whitespace. Perhaps you don't want to
use the HTML like this, for spacing or other issues. You could
always pass an string that grows down the recurse that provides the
indention:
<?cs def:display_files(files, spc) ?>
<?cs each:file = files ?>
<?cs var:spc ?><?cs var:file.Name ?><br>
<?cs if:file.Sub.0.Name ?>
<?cs call:display_files(file.Sub, spc + " ") ?>
<?cs /if ?>
<?cs /each ?>
<?cs /def ?>
<?cs call:display_files(Files, "") ?>
This version keeps growing a string of non-breakable spaces to place
in front of the file name, which makes for a slightly indented view.
You could then add something which checked the type and issued and
icon between the spaces and the name, etc.