/
file_list.php
executable file
·53 lines (48 loc) · 1.26 KB
/
file_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace PMVC\PlugIn\file_list;
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\file_list';
\PMVC\l(__DIR__ . '/src/FileList');
class file_list extends \PMVC\PlugIn
{
private $olist;
function init()
{
$this->olist = new FileList();
}
function ls(...$p)
{
if ($this['hash']) {
$this->olist->setChecksum($this['hash']);
}
if ($this['exclude']) {
$excludes = \PMVC\splitDir($this['exclude']);
foreach ($excludes as $exclude) {
$this->olist->addExclude($exclude);
}
}
if ($this['maskKey']) {
$this->olist->maskKey($this['maskKey']);
}
if ($this['debug']) {
$this->olist->debug = $this['debug'];
}
if ($this['callBack']) {
$this->olist->setCallBack($this['callBack']);
}
return $this->olist->get(...$p);
}
function rmdir($dir)
{
$list = $this->ls($dir);
foreach ($list as $item) {
$wholePath = $item['wholePath'];
if (is_file($wholePath)) {
unlink($wholePath);
} elseif (is_dir($wholePath)) {
rmdir($wholePath);
}
}
rmdir($dir);
}
}
?>