public function S3fsStream::mkdir in S3 File System 8.3
Same name and namespace in other branches
- 8.2 src/StreamWrapper/S3fsStream.php \Drupal\s3fs\StreamWrapper\S3fsStream::mkdir()
- 4.0.x src/StreamWrapper/S3fsStream.php \Drupal\s3fs\StreamWrapper\S3fsStream::mkdir()
Support for mkdir().
Parameters
string $uri: The URI to the directory to create.
int $mode: Permission flags - see mkdir().
int $options: A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.
Return value
bool TRUE if the directory was successfully created. Otherwise, FALSE.
Overrides PhpStreamWrapperInterface::mkdir
See also
http://php.net/manual/en/streamwrapper.mkdir.php
1 call to S3fsStream::mkdir()
- S3fsStream::writeCache in src/
StreamWrapper/ S3fsStream.php - Write an object's (and its ancestor folders') metadata to the cache.
File
- src/
StreamWrapper/ S3fsStream.php, line 964
Class
- S3fsStream
- Defines a Drupal s3 (s3://) stream wrapper class.
Namespace
Drupal\s3fs\StreamWrapperCode
public function mkdir($uri, $mode, $options) {
// Some Drupal plugins call mkdir with a trailing slash. We mustn't store
// that slash in the cache.
$uri = rtrim($uri, '/');
if (mb_strlen($uri) > S3fsServiceInterface::MAX_URI_LENGTH) {
return FALSE;
}
clearstatcache(TRUE, $uri);
// If this URI already exists in the cache, return TRUE if it's a folder
// (so that recursive calls won't improperly report failure when they
// reach an existing ancestor), or FALSE if it's a file (failure).
$test_metadata = $this
->readCache($uri);
if ($test_metadata) {
return (bool) $test_metadata['dir'];
}
$metadata = $this->s3fs
->convertMetadata($uri, []);
$this
->writeCache($metadata);
// If the STREAM_MKDIR_RECURSIVE option was specified, also create all the
// ancestor folders of this uri, except for the root directory.
$parent_dir = \Drupal::service('file_system')
->dirname($uri);
if ($options & STREAM_MKDIR_RECURSIVE && $this->streamWrapperManager::getTarget($parent_dir) != '') {
return $this
->mkdir($parent_dir, $mode, $options);
}
return TRUE;
}