function FileTransfer::sanitizePath

Same name in other branches
  1. 7.x includes/filetransfer/filetransfer.inc \FileTransfer::sanitizePath()
  2. 9 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::sanitizePath()
  3. 10 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::sanitizePath()
  4. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.