You are here

public function S3fsStreamWrapper::rename in S3 File System 7.3

Same name and namespace in other branches
  1. 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::rename()
  2. 7.2 S3fsStreamWrapper.inc \S3fsStreamWrapper::rename()

Overrides StreamWrapperInterface::rename

File

./S3fsStreamWrapper.inc, line 893
Drupal stream wrapper implementation for S3 File System.

Class

S3fsStreamWrapper
The stream wrapper class.

Code

public function rename($from_path, $to_path) {

  // Set access for new item in stream context.
  if (file_uri_scheme($from_path) != 'private') {
    stream_context_set_option($this->context, 's3', 'ACL', 'public-read');
  }

  // If parent succeeds in renaming, updated local metadata and cache.
  if (parent::rename($this
    ->convertUriToKeyedPath($from_path), $this
    ->convertUriToKeyedPath($to_path))) {
    $metadata = $this
      ->_read_cache($from_path);
    $metadata['uri'] = $to_path;
    $this
      ->_write_cache($metadata);
    $this
      ->_delete_cache($from_path);
    clearstatcache(TRUE, $from_path);
    clearstatcache(TRUE, $to_path);
    return TRUE;
  }
  else {
    return FALSE;
  }
}