public function S3fsStreamWrapper::dir_opendir in S3 File System 7
Same name and namespace in other branches
- 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::dir_opendir()
- 7.2 S3fsStreamWrapper.inc \S3fsStreamWrapper::dir_opendir()
Support for opendir().
Parameters
string $uri: A string containing the URI to the directory to open.
int $options: A flag used to enable safe_mode. This parameter is ignored: this wrapper doesn't support safe_mode.
Return value
bool TRUE on success.
Overrides StreamWrapperInterface::dir_opendir
See also
http://php.net/manual/en/streamwrapper.dir-opendir.php
File
- ./
S3fsStreamWrapper.inc, line 987 - Drupal stream wrapper implementation for S3 File System.
Class
- S3fsStreamWrapper
- The stream wrapper class.
Code
public function dir_opendir($uri, $options = NULL) {
$this
->_assert_constructor_called();
$this
->_debug("dir_opendir({$uri}, {$options}) called.");
if (!$this
->_uri_is_dir($uri)) {
return FALSE;
}
$bare_uri = rtrim($uri, '/');
$slash_uri = $bare_uri . '/';
// If this URI was originally s3://, the above code removed *both* slashes
// but only added one back. So we need to add back the second slash.
if ($slash_uri == 's3:/') {
$slash_uri = 's3://';
}
// Get the list of uris for files and folders which are children of the
// specified folder, but not grandchildren.
$and = db_and();
$and
->condition('uri', db_like($slash_uri) . '%', 'LIKE');
$and
->condition('uri', db_like($slash_uri) . '%/%', 'NOT LIKE');
$child_uris = db_select('s3fs_file', 's')
->fields('s', array(
'uri',
))
->condition($and)
->execute()
->fetchCol(0);
$this->dir = array();
foreach ($child_uris as $child_uri) {
$this->dir[] = basename($child_uri);
}
return TRUE;
}