forked from kyoda/php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocatefile.class.php
More file actions
65 lines (41 loc) · 1.22 KB
/
locatefile.class.php
File metadata and controls
65 lines (41 loc) · 1.22 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
<?php
class LocateFile
{
private $FILE_LIST = array();
private $DIR_LIST = array();
private function recursionList()
{
$tmp_dir = $this->DIR_LIST;
$this->DIR_LIST = array();
for ($i = 0, $l = count($tmp_dir); $i< $l; $i++) {
$dir = $tmp_dir[$i];
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$name = $dir."/".$file;
if (is_file($name)) {
$this->FILE_LIST[] = $name;
} elseif (is_dir($name)) {
if ($file !== "." && $file !== "..") {
$this->DIR_LIST[] = $name;
}
}
}
closedir($dh);
}
}
}
}
function getFileList($dir)
{
if (is_dir($dir)) {
$this->DIR_LIST[] = $dir;
while (!empty($this->DIR_LIST)) {
$this->recursionList();
}
} else {
exit("No dir");
}
return $this->FILE_LIST;
}
}