I thought it might be nice to allow people writing class libraries in PHP/PEAR to be able to roll-their-own streams using PHP code.
It would be implemented something like the user-mode session module handler, but a bit more OO; they would declare a class (see below) and register it as a wrapper using a new user-space function called file_register_wrapper(string $protocol, string $classname). file_register_wrapper would fail if the wrapper is already registered. The php_stream_open_wrapper function would create an instance of the class and then call it's methods when the equivalent methods in the php_stream_ops structure are called. This would allow some really cool things, like defining a custom protocol and then passing that custom URL around to all sorts of PHP functions (fopen(), copy(), extension functions that use wrappers) and have them handle it without even noticing that it's implemented in PHP code. Comments please! --Wez. class my_stream { function open($path, $mode, $options, &$opened_path) { return true/false; } function read($count) { return false on error; else return string; } function write($data) { return false on error; else return count written; } function close() { } function flush() { } /* these are optional */ function seek($offset, $whence) { } function gets($size) { return false on error; else return string; } } -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php