[Richard Suchenwirth] 2006-04-05 - A [VFS] (virtual filesystem) is an elaborate piece of engineering. This page is not. It's just an experiment in how to map tree-structured data in a kind of filesystem with directories. (The purpose is to provide an analogon to [glob], for opening [Tree] nodes for such a structure on demand.) For this, each "directory" is an array element, which contains its children with full path. set data { /foo/f1/g1 /foo/f1/g2 /foo/f2/g3 /foo/f2/g4 /bar/b1/hello /bar/b1/world /bar/b2/test /bar/b2/again } proc mkvfs {_arr data} { upvar 1 $_arr arr foreach item $data { set dir [file dir $item] if ![info exists arr($dir)] {set arr($dir) {}} if {$dir ne "/"} {mkvfs arr $dir} if {[lsearch -exact $arr($dir) $item]<0} { lappend arr($dir) $item } } } Test: % mkvfs arr $data % parray arr arr(/) = /foo /bar arr(/bar) = /bar/b1 /bar/b2 arr(/bar/b1) = /bar/b1/hello /bar/b1/world arr(/bar/b2) = /bar/b2/test /bar/b2/again arr(/foo) = /foo/f1 /foo/f2 arr(/foo/f1) = /foo/f1/g1 /foo/f1/g2 arr(/foo/f2) = /foo/f2/g3 /foo/f2/g4 ---- [Category Example] - [Arts and Crafts of Tcl-Tk programming]