<span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
class
</span><span style=
"color: #000000;"
> getFiles {
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$_dir
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$_emptyDir
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$_fileType
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #800080;"
>
$_files
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> __construct(<span style=
"color: #800080;"
>
$_dir
</span>,<span style=
"color: #800080;"
>
$_emptyDir
</span> = <span style=
"color: #0000ff;"
>false</span>,<span sty>
$_fileType
</span> = <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #800080;"
>
$this
</span>->_dir = <span style=
"color: #800080;"
>
$_dir
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$this
</span>->_emptyDir = <span style=
"color: #800080;"
>
$_emptyDir
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$this
</span>->_fileType = <span style=
"color: #800080;"
>
$_fileType
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>_emptyDir) {
</span><span style=
"color: #800080;"
>
$this
</span>->getFileEmpty(<span style=
"color: #800080;"
>
$this
</span>->_dir,<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>_files);
} </span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
> {
</span><span style=
"color: #800080;"
>
$this
</span>->getFile(<span style=
"color: #800080;"
>
$this
</span>->_dir,<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>_files);
}
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #0000ff;"
>
function
</span> getFile(<span style=
"color: #800080;"
>
$_dir
</span>,&<span style=
"color: #800080;"
>
$_arr
</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #0000ff;"
>
if
</span> (!!<span style=
"color: #800080;"
>
$_dirs
</span> = <span style=
"color: #008080;"
>opendir</span>(<span style=
"color: #800080;"
>
$_dir
</span><span style=
"color: #000000;"
>)) {
</span><span style=
"color: #0000ff;"
>
while
</span> ((<span style=
"color: #800080;"
>
$_file
</span>=<span style=
"color: #008080;"
>readdir</span>(<span style=
"color: #800080;"
>
$_dirs
</span>)) != <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #800080;"
>
$_file
</span> ==
'.'
|| <span style=
"color: #800080;"
>
$_file
</span> ==
'..'
) <span style=
"color: #0000ff;"
>
continue
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$_files
</span> = <span style=
"color: #800080;"
>
$_dir
</span> .
'/'
. <span style=
"color: #800080;"
>
$_file
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #008080;"
>
is_dir
</span>(<span style=
"color: #800080;"
>
$_files
</span><span style=
"color: #000000;"
>)) {
</span><span style=
"color: #800080;"
>
$this
</span>->getFile(<span style=
"color: #800080;"
>
$_files
</span>,<span style=
"color: #800080;"
>
$_arr
</span><span style=
"color: #000000;"
>);
} </span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
> {
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>_fileType) {
</span><span style=
"color: #800080;"
>
$_arr
</span>[] = <span style=
"color: #800080;"
>
$_files
</span><span style=
"color: #000000;"
>;
} </span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
> {
</span><span style=
"color: #800080;"
>
$_arr
</span>[] = <span style=
"color: #800080;"
>
$_file
</span><span style=
"color: #000000;"
>;
}
}
}
}
</span><span style=
"color: #008080;"
>
closedir
</span>(<span style=
"color: #800080;"
>
$_dirs
</span><span style=
"color: #000000;"
>);
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #0000ff;"
>
function
</span> getFileEmpty(<span style=
"color: #800080;"
>
$_dir
</span>,&<span style=
"color: #800080;"
>
$_arr
</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #0000ff;"
>
if
</span> (!!<span style=
"color: #800080;"
>
$_dirs
</span> = <span style=
"color: #008080;"
>opendir</span>(<span style=
"color: #800080;"
>
$_dir
</span><span style=
"color: #000000;"
>)) {
</span><span style=
"color: #0000ff;"
>
while
</span> ((<span style=
"color: #800080;"
>
$_file
</span>=<span style=
"color: #008080;"
>readdir</span>(<span style=
"color: #800080;"
>
$_dirs
</span>)) != <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #800080;"
>
$_file
</span> ==
'.'
|| <span style=
"color: #800080;"
>
$_file
</span> ==
'..'
) <span style=
"color: #0000ff;"
>
continue
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$_files
</span> = <span style=
"color: #800080;"
>
$_dir
</span> .
'/'
. <span style=
"color: #800080;"
>
$_file
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #008080;"
>
is_dir
</span>(<span style=
"color: #800080;"
>
$_files
</span>) && <span style=
"color: #800080;"
>
$this
</span>->isEmpty(<span style=
"color: #800080;"
>
$_files
</span><span style=
"color: #000000;"
>)) {
</span><span style=
"color: #800080;"
>
$this
</span>->getFileEmpty(<span style=
"color: #800080;"
>
$_files
</span>,<span style=
"color: #800080;"
>
$_arr
</span><span style=
"color: #000000;"
>);
} </span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
> {
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>_fileType) {
</span><span style=
"color: #800080;"
>
$_arr
</span>[] = <span style=
"color: #800080;"
>
$_files
</span><span style=
"color: #000000;"
>;
} </span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
> {
</span><span style=
"color: #800080;"
>
$_arr
</span>[] = <span style=
"color: #800080;"
>
$_file
</span><span style=
"color: #000000;"
>;
}
}
}
}
</span><span style=
"color: #008080;"
>
closedir
</span>(<span style=
"color: #800080;"
>
$_dirs
</span><span style=
"color: #000000;"
>);
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #0000ff;"
>
function
</span> isEmpty(<span style=
"color: #800080;"
>
$_dir
</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #0000ff;"
>
if
</span> (!!<span style=
"color: #800080;"
>
$_dirs
</span> = <span style=
"color: #008080;"
>opendir</span>(<span style=
"color: #800080;"
>
$_dir
</span><span style=
"color: #000000;"
>)) {
</span><span style=
"color: #0000ff;"
>
while
</span> ((<span style=
"color: #800080;"
>
$_file
</span>=<span style=
"color: #008080;"
>readdir</span>(<span style=
"color: #800080;"
>
$_dirs
</span>)) != <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>) {
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$_file
</span> !=
'.'
&& <span style=
"color: #800080;"
>
$_file
</span> !=
'..'
<span style=
"color: #000000;"
>) {
</span><span style=
"color: #008080;"
>
closedir
</span>(<span style=
"color: #800080;"
>
$_dirs
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
break
</span><span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #008080;"
>
closedir
</span>(<span style=
"color: #800080;"
>
$_dirs
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
}
}</span>