Hello developers!
I'm sticking in a problem.
I want to read the folder hierarchy of the webserver and store the
information in a tree, built like a linked list - you know 'a tree'.
you see in function readsubtree() i'm storing the object child in the
array of the actualfoldernod e. but this doesn't work out. it never
arrives there.
the tree is just built to one depth. although the recursion works as
some echo outs show.
please help
cheers
a-k
let me post in the snippet:
function readTree(){
global $name_of_root;
$this->rootNode = new FolderTreeNode( $this);
$this->rootNode->name = $name_of_root;
$this->rootNode->absPath = absolutePath("" );
if (relativePath(g etcwd()) == "") {$this->rootNode->selected = true;}
$this->readSubTree(&$ this->rootNode);
}
function readSubTree($ac tualFolderNode) {
$actualAbsDir = $actualFolderNo de->absPath;
$dir = @opendir($actua lAbsDir);
if (!$dir) {return 0;}
while ($entry = readdir($dir)){
if (is_dir($actual AbsDir."/".$entry) && ($entry != ".." && $entry !=
".")){
$child = new FolderTreeNode( $this);
$child->name = $entry;
$child->absPath = $actualAbsDir."/".$entry;
$child->parentNode = $actualFolderNo de;
if (getcwd() == $child->absPath) {$child->selected = true;}
$actualFolderNo de->childNodes[] = $child;
$this->readSubTree($c hild);
}
}
}
class FolderTreeNode{
var $folderTree;
var $name;
var $absPath;
var $parentNode;
var $childNodes = array();
var $selected;
var $newElements;
function FolderTreeNode( $folderTree){
$this->folderTree = $folderTree;
}
}
I'm sticking in a problem.
I want to read the folder hierarchy of the webserver and store the
information in a tree, built like a linked list - you know 'a tree'.
you see in function readsubtree() i'm storing the object child in the
array of the actualfoldernod e. but this doesn't work out. it never
arrives there.
the tree is just built to one depth. although the recursion works as
some echo outs show.
please help
cheers
a-k
let me post in the snippet:
function readTree(){
global $name_of_root;
$this->rootNode = new FolderTreeNode( $this);
$this->rootNode->name = $name_of_root;
$this->rootNode->absPath = absolutePath("" );
if (relativePath(g etcwd()) == "") {$this->rootNode->selected = true;}
$this->readSubTree(&$ this->rootNode);
}
function readSubTree($ac tualFolderNode) {
$actualAbsDir = $actualFolderNo de->absPath;
$dir = @opendir($actua lAbsDir);
if (!$dir) {return 0;}
while ($entry = readdir($dir)){
if (is_dir($actual AbsDir."/".$entry) && ($entry != ".." && $entry !=
".")){
$child = new FolderTreeNode( $this);
$child->name = $entry;
$child->absPath = $actualAbsDir."/".$entry;
$child->parentNode = $actualFolderNo de;
if (getcwd() == $child->absPath) {$child->selected = true;}
$actualFolderNo de->childNodes[] = $child;
$this->readSubTree($c hild);
}
}
}
class FolderTreeNode{
var $folderTree;
var $name;
var $absPath;
var $parentNode;
var $childNodes = array();
var $selected;
var $newElements;
function FolderTreeNode( $folderTree){
$this->folderTree = $folderTree;
}
}
Comment