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