Commit 8598721e authored by Taylor Otwell's avatar Taylor Otwell

added recursive rmdir function.

parent d9f3725a
......@@ -241,6 +241,39 @@ class File {
if ($delete) rmdir($source);
}
/**
* Recursively copy directory contents to another directory.
*
* @param string $source
* @param string $destination
* @param bool $delete
* @param int $options
* @return void
*/
public static function rmdir($directory)
{
if ( ! is_dir($directory)) return;
$items = new fIterator($directory);
foreach ($items as $item)
{
// If the item is a directory, we can just recurse into the
// function and delete that sub-directory, otherwise we'll
// just deleete the file and keep going!
if ($item->isDir())
{
static::rmdir($item->getRealPath());
}
else
{
@unlink($item->getRealPath());
}
}
@rmdir($directory);
}
/**
* Get the most recently modified file in a directory.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment