mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-08-27 15:09:44 +08:00
35 lines
684 B
PHP
35 lines
684 B
PHP
<?php
|
|
|
|
namespace League\Flysystem\Plugin;
|
|
|
|
class EmptyDir extends AbstractPlugin
|
|
{
|
|
/**
|
|
* Get the method name.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getMethod()
|
|
{
|
|
return 'emptyDir';
|
|
}
|
|
|
|
/**
|
|
* Empty a directory's contents.
|
|
*
|
|
* @param string $dirname
|
|
*/
|
|
public function handle($dirname)
|
|
{
|
|
$listing = $this->filesystem->listContents($dirname, false);
|
|
|
|
foreach ($listing as $item) {
|
|
if ($item['type'] === 'dir') {
|
|
$this->filesystem->deleteDir($item['path']);
|
|
} else {
|
|
$this->filesystem->delete($item['path']);
|
|
}
|
|
}
|
|
}
|
|
}
|