protected final static function wipeDir($dir, $rmdir = false) {
		if (file_exists($dir)) {
			$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
			$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
			foreach ($files as $file)

				if ($file->isDir())
					self::wipeDir($file->getRealPath(), true); //rmdir($file->getRealPath());
				else
					unlink($file->getRealPath());


			if ($rmdir)
				rmdir($dir);
		}
	}
protected final static function wipeDir($dir, $rmdir = false) {
		if (file_exists($dir)) {
			$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
			$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
			foreach ($files as $file)

				if ($file->isDir())
					self::wipeDir($file->getRealPath(), true); //rmdir($file->getRealPath());
				else
					unlink($file->getRealPath());


			if ($rmdir)
				rmdir($dir);
		}
	}
protected final static function wipeDir ( $ dir , $ rmdir = false ) { if ( file_exists ( $ dir ) ) { $ it = new \ RecursiveDirectoryIterator ( $ dir , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ files = new \ RecursiveIteratorIterator ( $ it , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ files as $ file ) if ( $ file -> isDir ( ) ) self :: wipeDir ( $ file -> getRealPath ( ) , true ) ; //rmdir($file->getRealPath()); else unlink ( $ file -> getRealPath ( ) ) ; if ( $ rmdir ) rmdir ( $ dir ) ; } }
Remove everything in a directory
@param string $dir directiory to wipe
@param boolean $rmdir remove directory also?
Remove everything in a directory