* Recursively removes a directory and its contents. * * @param string $dir The directory to remove. * @return void */
(string $dir)
| 1495 | * @return void |
| 1496 | */ |
| 1497 | private static function rrmdir(string $dir): void |
| 1498 | { |
| 1499 | if (!is_dir($dir)) { |
| 1500 | return; |
| 1501 | } |
| 1502 | $iterator = new RecursiveIteratorIterator( |
| 1503 | new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS), |
| 1504 | RecursiveIteratorIterator::CHILD_FIRST |
| 1505 | ); |
| 1506 | foreach ($iterator as $file) { |
| 1507 | if ($file->isDir()) { |
| 1508 | rmdir($file->getRealPath()); |
| 1509 | } else { |
| 1510 | unlink($file->getRealPath()); |
| 1511 | } |
| 1512 | } |
| 1513 | rmdir($dir); |
| 1514 | } |
| 1515 | |
| 1516 | /** |
| 1517 | * Removes the temporary chunk directory for resumable uploads. |
no outgoing calls
no test coverage detected