function FileTransfer::fixRemotePath

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::fixRemotePath()
  2. 7.x includes/filetransfer/filetransfer.inc \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 and $strip_chroot is TRUE, it is stripped from the path to allow for chroot'd filetransfer systems.

Parameters

string $path: The path to modify.

bool $strip_chroot: Whether to remove the path in $this->chroot.

Return value

string The modified path.

File

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

Class

FileTransfer
Defines the base FileTransfer class.

Namespace

Drupal\Core\FileTransfer

Code

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

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