protected Local::removeDirectoryJailed($directory)
Removes a directory.
Parameters
string $directory: The directory to be removed.
Overrides FileTransfer::removeDirectoryJailed
File
- core/lib/Drupal/Core/FileTransfer/Local.php, line 45
Class
- Local
- Defines the local connection class for copying files as the httpd user.
Namespace
Drupal\Core\FileTransfer
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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 )); } } |
Please login to continue.