function FileTransfer::fixRemotePath

Same name in other branches
  1. 9 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::fixRemotePath()
  2. 8.9.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::fixRemotePath()
  3. 10 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::fixRemotePath()
  4. 11.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::fixRemotePath()

Returns a modified path suitable for passing to the server. If a path is a windows path, makes it POSIX compliant by removing the drive letter. If $this->chroot has a value, it is stripped from the path to allow for chroot'd filetransfer systems.

Parameters

$path:

$strip_chroot:

Return value

string

9 calls to FileTransfer::fixRemotePath()
FileTransfer::checkPath in includes/filetransfer/filetransfer.inc
Checks that the path is inside the jail and throws an exception if not.
FileTransfer::chmod in includes/filetransfer/filetransfer.inc
FileTransfer::copyDirectory in includes/filetransfer/filetransfer.inc
Copies a directory.
FileTransfer::copyFile in includes/filetransfer/filetransfer.inc
Copies a file.
FileTransfer::createDirectory in includes/filetransfer/filetransfer.inc
Creates a directory.

... See full list

File

includes/filetransfer/filetransfer.inc, line 179

Class

FileTransfer

Code

protected final function fixRemotePath($path, $strip_chroot = TRUE) {
    $path = $this->sanitizePath($path);
    $path = preg_replace('|^([a-z]{1}):|i', '', $path);
    // Strip out windows driveletter if its there.
    if ($strip_chroot) {
        if ($this->chroot && strpos($path, $this->chroot) === 0) {
            $path = $path == $this->chroot ? '' : substr($path, strlen($this->chroot));
        }
    }
    return $path;
}

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