Defines the local connection class for copying files as the httpd user.
Expanded class hierarchy of Local
class Local extends FileTransfer implements ChmodInterface {
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::connect().
*/
function connect() {
// No-op
}
/**
* Overrides Drupal\Core\FileTransfer\FileTransfer::factory().
*/
static function factory($jail, $settings) {
return new Local($jail);
}
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::copyFileJailed().
*/
protected function copyFileJailed($source, $destination) {
if (@(!copy($source, $destination))) {
throw new FileTransferException('Cannot copy %source to %destination.', NULL, array(
'%source' => $source,
'%destination' => $destination,
));
}
}
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::createDirectoryJailed().
*/
protected function createDirectoryJailed($directory) {
if (!is_dir($directory) && @(!mkdir($directory, 0777, TRUE))) {
throw new FileTransferException('Cannot create directory %directory.', NULL, array(
'%directory' => $directory,
));
}
}
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::removeDirectoryJailed().
*/
protected function removeDirectoryJailed($directory) {
if (!is_dir($directory)) {
// Programmer error assertion, not something we expect users to see.
throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array(
'%directory' => $directory,
));
}
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
if ($file
->isDir()) {
if (@(!drupal_rmdir($filename))) {
throw new FileTransferException('Cannot remove directory %directory.', NULL, array(
'%directory' => $filename,
));
}
}
elseif ($file
->isFile()) {
if (@(!drupal_unlink($filename))) {
throw new FileTransferException('Cannot remove file %file.', NULL, array(
'%file' => $filename,
));
}
}
}
if (@(!drupal_rmdir($directory))) {
throw new FileTransferException('Cannot remove directory %directory.', NULL, array(
'%directory' => $directory,
));
}
}
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::removeFileJailed().
*/
protected function removeFileJailed($file) {
if (@(!drupal_unlink($file))) {
throw new FileTransferException('Cannot remove file %file.', NULL, array(
'%file' => $file,
));
}
}
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::isDirectory().
*/
public function isDirectory($path) {
return is_dir($path);
}
/**
* Implements Drupal\Core\FileTransfer\FileTransfer::isFile().
*/
public function isFile($path) {
return is_file($path);
}
/**
* Implements Drupal\Core\FileTransfer\ChmodInterface::chmodJailed().
*/
public function chmodJailed($path, $mode, $recursive) {
if ($recursive && is_dir($path)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
if (@(!chmod($filename, $mode))) {
throw new FileTransferException('Cannot chmod %path.', NULL, array(
'%path' => $filename,
));
}
}
}
elseif (@(!chmod($path, $mode))) {
throw new FileTransferException('Cannot chmod %path.', NULL, array(
'%path' => $path,
));
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileTransfer:: |
protected | property | The hostname for this file transfer. | |
FileTransfer:: |
protected | property | The password for this file transfer. | 1 |
FileTransfer:: |
protected | property | The port for this file transfer. | 1 |
FileTransfer:: |
protected | property | The username for this file transfer. | 1 |
FileTransfer:: |
final protected | function | Checks that the path is inside the jail and throws an exception if not. | |
FileTransfer:: |
final public | function | Changes the permissions of the specified $path (file or directory). | |
FileTransfer:: |
final public | function | Copies a directory. | |
FileTransfer:: |
protected | function | Copies a directory. | 1 |
FileTransfer:: |
final public | function | Copies a file. | |
FileTransfer:: |
final public | function | Creates a directory. | |
FileTransfer:: |
function | Returns the chroot property for this connection. | ||
FileTransfer:: |
final protected | function | Returns a modified path suitable for passing to the server. | |
FileTransfer:: |
public | function | Returns a form to collect connection settings credentials. | 2 |
FileTransfer:: |
final public | function | Removes a directory. | |
FileTransfer:: |
final public | function | Removes a file. | |
FileTransfer:: |
function | Changes backslashes to slashes, also removes a trailing slash. | ||
FileTransfer:: |
function | Sets the chroot and changes the jail to match the correct path scheme. | ||
FileTransfer:: |
function | Constructs a Drupal\Core\FileTransfer\FileTransfer object. | 3 | |
FileTransfer:: |
function | Implements the magic __get() method. | ||
Local:: |
public | function |
Implements Drupal\Core\FileTransfer\ChmodInterface::chmodJailed(). Overrides ChmodInterface:: |
|
Local:: |
function |
Implements Drupal\Core\FileTransfer\FileTransfer::connect(). Overrides FileTransfer:: |
||
Local:: |
protected | function |
Implements Drupal\Core\FileTransfer\FileTransfer::copyFileJailed(). Overrides FileTransfer:: |
|
Local:: |
protected | function |
Implements Drupal\Core\FileTransfer\FileTransfer::createDirectoryJailed(). Overrides FileTransfer:: |
|
Local:: |
static | function |
Overrides Drupal\Core\FileTransfer\FileTransfer::factory(). Overrides FileTransfer:: |
|
Local:: |
public | function |
Implements Drupal\Core\FileTransfer\FileTransfer::isDirectory(). Overrides FileTransfer:: |
|
Local:: |
public | function |
Implements Drupal\Core\FileTransfer\FileTransfer::isFile(). Overrides FileTransfer:: |
|
Local:: |
protected | function |
Implements Drupal\Core\FileTransfer\FileTransfer::removeDirectoryJailed(). Overrides FileTransfer:: |
|
Local:: |
protected | function |
Implements Drupal\Core\FileTransfer\FileTransfer::removeFileJailed(). Overrides FileTransfer:: |