class FileTransferLocal in Drupal 7
The local connection class for copying files as the httpd user.
Hierarchy
- class \FileTransfer
- class \FileTransferLocal implements FileTransferChmodInterface
Expanded class hierarchy of FileTransferLocal
File
- includes/
filetransfer/ local.inc, line 6
View source
class FileTransferLocal extends FileTransfer implements FileTransferChmodInterface {
function connect() {
// No-op
}
static function factory($jail, $settings) {
return new FileTransferLocal($jail);
}
protected function copyFileJailed($source, $destination) {
if (@(!copy($source, $destination))) {
throw new FileTransferException('Cannot copy %source to %destination.', NULL, array(
'%source' => $source,
'%destination' => $destination,
));
}
}
protected function createDirectoryJailed($directory) {
if (!is_dir($directory) && @(!mkdir($directory, 0777, TRUE))) {
throw new FileTransferException('Cannot create directory %directory.', NULL, array(
'%directory' => $directory,
));
}
}
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 SkipDotsRecursiveDirectoryIterator($directory), 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,
));
}
}
protected function removeFileJailed($file) {
if (@(!drupal_unlink($file))) {
throw new FileTransferException('Cannot remove file %file.', NULL, array(
'%file' => $file,
));
}
}
public function isDirectory($path) {
return is_dir($path);
}
public function isFile($path) {
return is_file($path);
}
public function chmodJailed($path, $mode, $recursive) {
if ($recursive && is_dir($path)) {
foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($path), 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,
));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileTransfer:: |
protected | property | ||
FileTransfer:: |
protected | property | 1 | |
FileTransfer:: |
protected | property | 1 | |
FileTransfer:: |
protected | property | 1 | |
FileTransfer:: |
final protected | function | Checks that the path is inside the jail and throws an exception if not. | |
FileTransfer:: |
final public | function | ||
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 | Return the chroot property for this connection. | ||
FileTransfer:: |
final protected | function | 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. | |
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 | The constructor for the UpdateConnection class. This method is also called from the classes that extend this class and override this method. | 3 | |
FileTransfer:: |
function | Implementation of the magic __get() method. | ||
FileTransferLocal:: |
public | function |
Changes the permissions of the file / directory specified in $path Overrides FileTransferChmodInterface:: |
|
FileTransferLocal:: |
function |
Connect to the server. Overrides FileTransfer:: |
||
FileTransferLocal:: |
protected | function |
Copies a file. Overrides FileTransfer:: |
|
FileTransferLocal:: |
protected | function |
Creates a directory. Overrides FileTransfer:: |
|
FileTransferLocal:: |
static | function |
Classes that extend this class must override the factory() static method. Overrides FileTransfer:: |
|
FileTransferLocal:: |
public | function |
Checks if a particular path is a directory Overrides FileTransfer:: |
|
FileTransferLocal:: |
public | function |
Checks if a particular path is a file (not a directory). Overrides FileTransfer:: |
|
FileTransferLocal:: |
protected | function |
Removes a directory. Overrides FileTransfer:: |
|
FileTransferLocal:: |
protected | function |
Removes a file. Overrides FileTransfer:: |