function FileTransfer::findChroot
Same name in other branches
- 9 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::findChroot()
- 8.9.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::findChroot()
- 10 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::findChroot()
- 11.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::findChroot()
Return the chroot property for this connection.
It does this by moving up the tree until it finds itself. If successful, it will return the chroot, otherwise FALSE.
Return value
The chroot path for this connection or FALSE.
1 call to FileTransfer::findChroot()
- FileTransfer::setChroot in includes/
filetransfer/ filetransfer.inc - Sets the chroot and changes the jail to match the correct path scheme
File
-
includes/
filetransfer/ filetransfer.inc, line 293
Class
Code
function findChroot() {
// If the file exists as is, there is no chroot.
$path = __FILE__;
$path = $this->fixRemotePath($path, FALSE);
if ($this->isFile($path)) {
return FALSE;
}
$path = dirname(__FILE__);
$path = $this->fixRemotePath($path, FALSE);
$parts = explode('/', $path);
$chroot = '';
while (count($parts)) {
$check = implode('/', $parts);
if ($this->isFile($check . '/' . drupal_basename(__FILE__))) {
// Remove the trailing slash.
return substr($chroot, 0, -1);
}
$chroot .= array_shift($parts) . '/';
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.