diff --git a/functions/filesystem.xml b/functions/filesystem.xml index 21752acbf0..23e847db38 100644 --- a/functions/filesystem.xml +++ b/functions/filesystem.xml @@ -1,5 +1,5 @@ - + Filesystem functions Filesystem @@ -669,6 +669,89 @@ fclose ($fd); + + + file_register_wrapper + Register a URL wrapper implemented as a PHP class + + + Description + + booleanfile_register_wrapper + stringprotocol + stringclassname + + + This function is currently only documented by the example below: + + Implementing a base64 encoding protocol + +fp = fopen($path, $mode); + return is_resource($this->fp); + } + function stream_close() + { + fclose($this->fp); + } + function stream_read($count) + { + return false; // We only allow writing + } + function stream_write($data) + { + return fwrite($this->fp, base64_encode($data)); + } + function stream_flush() + { + fflush($this->fp); + return true; + } + function stream_seek($offset, $whence) + { + return false; + } + function stream_gets() + { + return false; + } + function stream_tell() + { + return false; + } + function stream_eof() + { + return false; + } +} +file_register_wrapper("base64", "Base64EncodingStream") + or die("Failed to register protocol"); + +copy("/tmp/inputfile.txt", "base64:///tmp/outputfile.txt"); +readfile("/tmp/outputfile"); +]]> + + + + + + file_register_wrapper will return false if the + protocol already has a handler, or if "fopen + wrappers" are disabled. + + + + This function was introduced in PHP 4.3.0. + + + + + file_get_contents @@ -685,6 +768,11 @@ fclose ($fd); Identical to readfile, except that file_get_contents returns the file in a string. + + + This function was introduced in PHP 4.3.0. + + ¬e.bin-safe; &tip.fopen-wrapper; @@ -1157,15 +1245,15 @@ $fcontents = implode ('', file ('http://www.example.com/')); - + - fgetwrapperdata + file_get_wrapper_data Retrieves header/meta data from "wrapped" file pointers Description - mixedfgetwrapperdata + mixedfile_get_wrapper_data intfp @@ -1176,7 +1264,7 @@ $fcontents = implode ('', file ('http://www.example.com/')); The format of the returned data is deliberately undocumented at this - time. + time, and depends on which wrapper(s) were used to open the file. @@ -1218,7 +1306,7 @@ $fcontents = implode ('', file ('http://www.example.com/')); response header you need to be using PHP 4.0.5 or later; The headers will be stored in the $http_response_header variable. As of PHP 4.3.0 (not yet released), the header information can - be retrieved using the fgetwrapperdata. + be retrieved using the file_get_wrapper_data. HTTP connections are read-only; you cannot write data or copy