ILIAS  release_7 Revision v7.30-3-g800a261c036
rmdirs.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 2020 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8if (php_sapi_name() !== 'cli') {
9 exit();
10}
11
13 __DIR__ . '/vendor/geshi/geshi/contrib',
14];
15
16foreach ($dirsToDeleted as $directoryPath) {
17 try {
18 if (!is_dir($directoryPath)) {
19 continue;
20 }
21
22 $recursiveDirIter = new RecursiveDirectoryIterator($directoryPath, FilesystemIterator::SKIP_DOTS);
23 $resourceIter = new RecursiveIteratorIterator($recursiveDirIter, RecursiveIteratorIterator::CHILD_FIRST);
24 foreach ($resourceIter as $resource) {
26 if ($resource->isDir()) {
27 rmdir($resource->getPathname());
28 } else {
29 unlink($resource->getPathname());
30 }
31 echo "Deleted " . $resource->getPathname() . "\n";
32 }
33 rmdir($directoryPath);
34 echo "Deleted " . $directoryPath . "\n";
35 } catch (Exception $e) {
36 echo $e->getMessage() . "\n";
37 }
38}
An exception for terminatinating execution or to throw for unit testing.
exit
Definition: login.php:29
if(php_sapi_name() !=='cli') $dirsToDeleted
Definition: rmdirs.php:12