public function S3fsStreamWrapper::mkdir in S3 File System 7.2
Same name and namespace in other branches
- 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::mkdir()
- 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::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 StreamWrapperInterface::mkdir
See also
http://php.net/manual/en/streamwrapper.mkdir.php
1 call to S3fsStreamWrapper::mkdir()
- S3fsStreamWrapper::_write_cache in ./
S3fsStreamWrapper.inc - Write an object's (and its ancestor folders') metadata to the cache.
File
- ./
S3fsStreamWrapper.inc, line 943 - Drupal stream wrapper implementation for S3 File System.
Class
- S3fsStreamWrapper
- The stream wrapper class.
Code
public function mkdir($uri, $mode, $options) {
$this
->_assert_constructor_called();
$this
->_debug("mkdir({$uri}, {$mode}, {$options}) called.");
// Some Drupal plugins call mkdir with a trailing slash. We mustn't store
// that slash in the cache.
$uri = rtrim($uri, '/');
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
->_read_cache($uri);
if ($test_metadata) {
return (bool) $test_metadata['dir'];
}
// S3 is a flat file system, with no concept of directories (just files
// with slashes in their names). We store folders in the metadata cache,
// but don't create an object for them in S3.
$metadata = _s3fs_convert_metadata($uri, array());
$this
->_write_cache($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_dirname($uri);
if ($options & STREAM_MKDIR_RECURSIVE && file_uri_target($parent_dir) != '') {
return $this
->mkdir($parent_dir, $mode, $options);
}
return TRUE;
}