Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / includes / file.inc
index b6ab267e4f6e103ac38e373a66f0131d4d8fbeb9..e532bf1d08ce54a4e401d0f8152ef6812685c42c 100644 (file)
@@ -462,8 +462,9 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
   }
   // Attempt to resolve the URIs. This is necessary in certain configurations
   // (see above).
-  $real_source = drupal_realpath($source) ?: $source;
-  $real_destination = drupal_realpath($destination) ?: $destination;
+  $file_system = \Drupal::service('file_system');
+  $real_source = $file_system->realpath($source) ?: $source;
+  $real_destination = $file_system->realpath($destination) ?: $destination;
   // Perform the copy operation.
   if (!@copy($real_source, $real_destination)) {
     \Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', ['%file' => $source, '%destination' => $destination]);
@@ -507,12 +508,13 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
 function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_EXISTS_RENAME) {
   $original_source = $source;
   $logger = \Drupal::logger('file');
+  $file_system = \Drupal::service('file_system');
 
   // Assert that the source file actually exists.
   if (!file_exists($source)) {
     // @todo Replace drupal_set_message() calls with exceptions instead.
     drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', ['%file' => $original_source]), 'error');
-    if (($realpath = drupal_realpath($original_source)) !== FALSE) {
+    if (($realpath = $file_system->realpath($original_source)) !== FALSE) {
       $logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', ['%file' => $original_source, '%realpath' => $realpath]);
     }
     else {
@@ -551,8 +553,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
   }
 
   // Assert that the source and destination filenames are not the same.
-  $real_source = drupal_realpath($source);
-  $real_destination = drupal_realpath($destination);
+  $real_source = $file_system->realpath($source);
+  $real_destination = $file_system->realpath($destination);
   if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
     drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', ['%file' => $source]), 'error');
     $logger->notice('File %file could not be moved/copied because it would overwrite itself.', ['%file' => $source]);
@@ -652,8 +654,9 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
   }
   // Attempt to resolve the URIs. This is necessary in certain configurations
   // (see above) and can also permit fast moves across local schemes.
-  $real_source = drupal_realpath($source) ?: $source;
-  $real_destination = drupal_realpath($destination) ?: $destination;
+  $file_system = \Drupal::service('file_system');
+  $real_source = $file_system->realpath($source) ?: $source;
+  $real_destination = $file_system->realpath($destination) ?: $destination;
   // Perform the move operation.
   if (!@rename($real_source, $real_destination)) {
     // Fall back to slow copy and unlink procedure. This is necessary for
@@ -892,7 +895,7 @@ function file_unmanaged_delete($path) {
  *
  * @param $path
  *   A string containing either an URI or a file or directory path.
- * @param $callback
+ * @param callable $callback
  *   (optional) Callback function to run on each file prior to deleting it and
  *   on each directory prior to traversing it. For example, can be used to
  *   modify permissions.