Mercurial > hg > cmmr2012-drupal-site
comparison core/lib/Drupal/Core/StreamWrapper/LocalStream.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
132 } | 132 } |
133 | 133 |
134 $realpath = realpath($path); | 134 $realpath = realpath($path); |
135 if (!$realpath) { | 135 if (!$realpath) { |
136 // This file does not yet exist. | 136 // This file does not yet exist. |
137 $realpath = realpath(dirname($path)) . '/' . drupal_basename($path); | 137 $realpath = realpath(dirname($path)) . '/' . \Drupal::service('file_system')->basename($path); |
138 } | 138 } |
139 $directory = realpath($this->getDirectoryPath()); | 139 $directory = realpath($this->getDirectoryPath()); |
140 if (!$realpath || !$directory || strpos($realpath, $directory) !== 0) { | 140 if (!$realpath || !$directory || strpos($realpath, $directory) !== 0) { |
141 return FALSE; | 141 return FALSE; |
142 } | 142 } |
395 } | 395 } |
396 | 396 |
397 /** | 397 /** |
398 * Gets the name of the directory from a given path. | 398 * Gets the name of the directory from a given path. |
399 * | 399 * |
400 * This method is usually accessed through drupal_dirname(), which wraps | 400 * This method is usually accessed through |
401 * around the PHP dirname() function because it does not support stream | 401 * \Drupal\Core\File\FileSystemInterface::dirname(), which wraps around the |
402 * wrappers. | 402 * PHP dirname() function because it does not support stream wrappers. |
403 * | 403 * |
404 * @param string $uri | 404 * @param string $uri |
405 * A URI or path. | 405 * A URI or path. |
406 * | 406 * |
407 * @return string | 407 * @return string |
408 * A string containing the directory name. | 408 * A string containing the directory name. |
409 * | 409 * |
410 * @see drupal_dirname() | 410 * @see \Drupal\Core\File\FileSystemInterface::dirname() |
411 */ | 411 */ |
412 public function dirname($uri = NULL) { | 412 public function dirname($uri = NULL) { |
413 list($scheme) = explode('://', $uri, 2); | 413 list($scheme) = explode('://', $uri, 2); |
414 $target = $this->getTarget($uri); | 414 $target = $this->getTarget($uri); |
415 $dirname = dirname($target); | 415 $dirname = dirname($target); |
445 $localpath = $this->getDirectoryPath() . '/' . $this->getTarget($uri); | 445 $localpath = $this->getDirectoryPath() . '/' . $this->getTarget($uri); |
446 } | 446 } |
447 else { | 447 else { |
448 $localpath = $this->getLocalPath($uri); | 448 $localpath = $this->getLocalPath($uri); |
449 } | 449 } |
450 /** @var \Drupal\Core\File\FileSystemInterface $file_system */ | |
451 $file_system = \Drupal::service('file_system'); | |
450 if ($options & STREAM_REPORT_ERRORS) { | 452 if ($options & STREAM_REPORT_ERRORS) { |
451 return drupal_mkdir($localpath, $mode, $recursive); | 453 return $file_system->mkdir($localpath, $mode, $recursive); |
452 } | 454 } |
453 else { | 455 else { |
454 return @drupal_mkdir($localpath, $mode, $recursive); | 456 return @$file_system->mkdir($localpath, $mode, $recursive); |
455 } | 457 } |
456 } | 458 } |
457 | 459 |
458 /** | 460 /** |
459 * Support for rmdir(). | 461 * Support for rmdir(). |
468 * | 470 * |
469 * @see http://php.net/manual/streamwrapper.rmdir.php | 471 * @see http://php.net/manual/streamwrapper.rmdir.php |
470 */ | 472 */ |
471 public function rmdir($uri, $options) { | 473 public function rmdir($uri, $options) { |
472 $this->uri = $uri; | 474 $this->uri = $uri; |
475 /** @var \Drupal\Core\File\FileSystemInterface $file_system */ | |
476 $file_system = \Drupal::service('file_system'); | |
473 if ($options & STREAM_REPORT_ERRORS) { | 477 if ($options & STREAM_REPORT_ERRORS) { |
474 return drupal_rmdir($this->getLocalPath()); | 478 return $file_system->rmdir($this->getLocalPath()); |
475 } | 479 } |
476 else { | 480 else { |
477 return @drupal_rmdir($this->getLocalPath()); | 481 return @$file_system->rmdir($this->getLocalPath()); |
478 } | 482 } |
479 } | 483 } |
480 | 484 |
481 /** | 485 /** |
482 * Support for stat(). | 486 * Support for stat(). |