Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 49 |
| Local | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
650 | |
0.00% |
0 / 49 |
| connect | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| factory | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| copyFileJailed | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| createDirectoryJailed | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
| removeDirectoryJailed | |
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 19 |
|||
| removeFileJailed | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| isDirectory | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| isFile | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| chmodJailed | |
0.00% |
0 / 1 |
42 | |
0.00% |
0 / 11 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\Core\FileTransfer\Local. | |
| */ | |
| namespace Drupal\Core\FileTransfer; | |
| /** | |
| * Defines the local connection class for copying files as the httpd user. | |
| */ | |
| class Local extends FileTransfer implements ChmodInterface { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function connect() { | |
| // No-op | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| static function factory($jail, $settings) { | |
| return new Local($jail); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function copyFileJailed($source, $destination) { | |
| if (@!copy($source, $destination)) { | |
| throw new FileTransferException('Cannot copy %source to %destination.', NULL, array('%source' => $source, '%destination' => $destination)); | |
| } | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function createDirectoryJailed($directory) { | |
| if (!is_dir($directory) && @!mkdir($directory, 0777, TRUE)) { | |
| throw new FileTransferException('Cannot create directory %directory.', NULL, array('%directory' => $directory)); | |
| } | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| 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)); | |
| } | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function removeFileJailed($file) { | |
| if (@!drupal_unlink($file)) { | |
| throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $file)); | |
| } | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function isDirectory($path) { | |
| return is_dir($path); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function isFile($path) { | |
| return is_file($path); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| 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)); | |
| } | |
| } | |
| } |