public function S3fsStreamWrapper::mkdir in S3 File System 7
Same name and namespace in other branches
- 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::mkdir()
- 7.2 S3fsStreamWrapper.inc \S3fsStreamWrapper::mkdir()
Support for mkdir().
Parameters
string $uri: A string containing 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 directory was successfully created.
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 862 - 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.");
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 anything in S3.
$metadata = _s3fs_convert_metadata($uri, array());
$metadata['timestamp'] = date('U', time());
$this
->_write_cache($metadata);
// If the STREAM_MKDIR_RECURSIVE option was specified, also create all the
// ancestor folders of this uri.
$parent_dir = drupal_dirname($uri);
if ($options & STREAM_MKDIR_RECURSIVE && $parent_dir != 's3://') {
return $this
->mkdir($parent_dir, $mode, $options);
}
return TRUE;
}