mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 03:43:08 +01:00
Added listFiles() function
This commit is contained in:
parent
39401e882b
commit
1f069e41e2
1 changed files with 23 additions and 0 deletions
|
@ -557,4 +557,27 @@ function LSdebugDefined() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List files in a directory corresponding to a regex
|
||||||
|
*
|
||||||
|
* @param[in] $dir The path of the directory
|
||||||
|
* @param[in] $regex The regex apply on filename
|
||||||
|
*
|
||||||
|
* @retval array() List of file name
|
||||||
|
**/
|
||||||
|
function listFiles($dir,$regex) {
|
||||||
|
$retval=array();
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
$d = dir($dir);
|
||||||
|
while (false !== ($file = $d->read())) {
|
||||||
|
if (is_file("$dir/$file")) {
|
||||||
|
if (preg_match($regex,$file)) {
|
||||||
|
$retval[]=$file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue