Thanks Peter.
We don't have a good reason for omitting the filesystem example in PHP. We'll add this to the manual.
Here is the PHP code for the client:
Code:
<?php
Ice_loadProfile();
// Recursively print the contents of directory "dir"
// in tree fashion. For files, show the contents of
// each file. The "depth" parameter is the current
// nesting level (for indentation).
function listRecursive($dir, $depth = 0)
{
$indent = str_repeat("\t", ++$depth);
$contents = $dir->_list(); // list is a reserved word in PHP
foreach ($contents as $i) {
$dir = $i->ice_checkedCast("::Filesystem::Directory");
$file = $i->ice_uncheckedCast("::Filesystem::File");
echo $indent . $i->name() .
($dir ? " (directory):" : " (file):") . "\n";
if ($dir) {
listRecursive($dir, $depth);
} else {
$text = $file->read();
foreach ($text as $j)
echo $indent . "\t" . $j . "\n";
}
}
}
try
{
// Create a proxy for the root directory
//
$base = $ICE->stringToProxy("RootDir:default -p 10000");
// Down-cast the proxy to a Directory proxy
//
$rootDir = $base->ice_checkedCast("::Filesystem::Directory");
// Recursively list the contents of the root directory
//
echo "Contents of root directory:\n";
listRecursive($rootDir);
}
catch(Ice_LocalException $ex)
{
print_r($ex);
}
?>
Take care,
- Mark