You are here

public function FileTransfer::sanitizePath in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::sanitizePath()

Changes backslashes to slashes, also removes a trailing slash.

Parameters

string $path: The path to modify.

Return value

string The modified path.

4 calls to FileTransfer::sanitizePath()
FileTransfer::chmod in core/lib/Drupal/Core/FileTransfer/FileTransfer.php
Changes the permissions of the specified $path (file or directory).
FileTransfer::copyDirectory in core/lib/Drupal/Core/FileTransfer/FileTransfer.php
Copies a directory.
FileTransfer::copyFile in core/lib/Drupal/Core/FileTransfer/FileTransfer.php
Copies a file.
FileTransfer::fixRemotePath in core/lib/Drupal/Core/FileTransfer/FileTransfer.php
Returns a modified path suitable for passing to the server.

File

core/lib/Drupal/Core/FileTransfer/FileTransfer.php, line 254

Class

FileTransfer
Defines the base FileTransfer class.

Namespace

Drupal\Core\FileTransfer

Code

public function sanitizePath($path) {

  // Windows path sanitization.
  $path = str_replace('\\', '/', $path);
  if (substr($path, -1) == '/') {
    $path = substr($path, 0, -1);
  }
  return $path;
}