Re: Virtual Filesystem
| From: | Wez Furlong | Date: | Sat, 28 Sep 2002 11:29:34 +0000 |
| Subject: | Re: Virtual Filesystem | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9635@lists.php.net to get a copy of this message | ||
I'm not a pear-dev regular, but saw something about virtual filesystem in
the CVS commit
log for the weekly news.
PHP 4.3 will (as of a little bit later today) allow you to create your own
classes to handle
directories using the same mechanism as the user-space streams. That means
that you will
be able to write code a little bit like this, that uses regular PHP opendir,
readdir, stat etc.
filesystem functions:
class myprotocolhandlerclass {
function dir_opendir($url)
{
return true;
}
function dir_readdir()
{
return "next_filename_in_dir";
// return false; when there are no more entries
}
function dir_rewinddir()
{
// make sure that the next call to dir_readdir will return
// the first entry again
}
function dir_closedir()
{
// release resources allocated in dir_opendir()
}
function stat_url($url)
{
// examine the resource indicated by $url and fill out an
// array with the same structure as that returned by stat(),
// or false if the resource can't be stat'ed or there is an error.
return array("ctime" => ... );
}
}
file_register_wrapper("myprotocol", "myprotocolhandlerclass");
$dir = opendir("myprotocol://path/to/dir");
while(($filename = readdir($dir)) !== false) {
echo $filename . "\n";
print_r(stat("myprotocol://path/to/dir/$filename"));
}
--Wez.
"Jon Wood" <jon@jellybob.co.uk> wrote in message
news:1032827585.3d8fb2c17d36b@www.thewoods.org...
> I think I've finished stripping out the Horde API references from the VFS
> class - you can take a look at what I've got so far at
> www.thewoods.org/~jon/vfs.php.
>
> You can navigate the directory which the source files are kept in using
their
> own example file ;)
>
> Jon