Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
FileHelper.php
1 <?php
2 /**
3  * Created by JetBrains PhpStorm.
4  * User: andrew
5  * Date: 5/4/12
6  * Time: 5:29 PM
7  * To change this template use File | Settings | File Templates.
8  */
9 class FileHelper
10 {
11 
12 
13  /**
14  * Removes directory recursively
15  *
16  * @param string $path Path to the directory.
17  *
18  * @return bool true on success or false on failure.
19  */
20  public static function rmdirr($path)
21  {
22  $iterator = new RecursiveIteratorIterator(
23  new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST
24  );
25  foreach ($iterator as $file) {
26  if ($file->isDir()) {
27  self::rmdirr($file->getPathname());
28  } else {
29  unlink($file->getPathname());
30  }
31  }
32  return rmdir($path);
33  }
34 }