public function DrupalRemoteStreamWrapper::stream_open in Remote Stream Wrapper 7
Support for fopen(), file_get_contents(), file_put_contents() etc.
Parameters
$uri: A string containing the URI to the file to open.
$mode: The file mode ("r", "wb" etc.).
$options: A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
&$opened_path: A string containing the path actually opened.
Return value
Returns TRUE if file was opened successfully.
Overrides StreamWrapperInterface::stream_open
See also
http://php.net/manual/en/streamwrapper.stream-open.php
File
- ./
remote_stream_wrapper.inc, line 132
Class
- DrupalRemoteStreamWrapper
- Stream wrapper to support local files.
Code
public function stream_open($uri, $mode, $options, &$opened_path) {
$this->uri = $uri;
$allowed_modes = array(
'r',
'rb',
);
if (!in_array($mode, $allowed_modes)) {
return FALSE;
}
// Attempt to fetch the URL's data using drupal_http_request().
if (!$this
->getStreamContent()) {
return FALSE;
}
// Reset the stream pointer since this is an open.
$this->stream_pointer = 0;
return TRUE;
}