This commit is contained in:
Cheese 2015-07-07 16:51:57 +10:00
parent bcc7e1fb65
commit b0bbbf506a
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace mineplex\plugin\util;
class UtilFile
{
public static function deleteDir($dirPath)
{
if (! is_dir($dirPath))
{
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/')
{
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file)
{
if (is_dir($file))
{
self::deleteDir($file);
}
else
{
unlink($file);
}
}
rmdir($dirPath);
}
}