本文整理汇总了PHP中files::getDirList方法的典型用法代码示例。如果您正苦于以下问题:PHP files::getDirList方法的具体用法?PHP files::getDirList怎么用?PHP files::getDirList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类files
的用法示例。
在下文中一共展示了files::getDirList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDirList
/**
* Recursive directory scanning
*
* Returns an array of a given directory's content. The array contains
* two arrays: dirs and files. Directory's content is fetched recursively.
*
* @param string $dirName Directory name
* @param array $contents Contents array. Leave it empty
* @return array
*/
public static function getDirList($dirName, &$contents = null)
{
if (!$contents) {
$contents = array('dirs' => array(), 'files' => array());
}
$exclude_list = array('.', '..', '.svn');
if (empty($res)) {
$res = array();
}
$dirName = preg_replace('|/$|', '', $dirName);
if (!is_dir($dirName)) {
throw new Exception(sprintf(__('%s is not a directory.'), $dirName));
}
$contents['dirs'][] = $dirName;
$d = @dir($dirName);
if ($d === false) {
throw new Exception(__('Unable to open directory.'));
}
while ($entry = $d->read()) {
if (!in_array($entry, $exclude_list)) {
if (is_dir($dirName . '/' . $entry)) {
files::getDirList($dirName . '/' . $entry, $contents);
} else {
$contents['files'][] = $dirName . '/' . $entry;
}
}
}
$d->close();
return $contents;
}
示例2: removeAssetsFiles
protected function removeAssetsFiles($sAssetsDir, $aLockedFiles = array())
{
$aFiles = files::getDirList($sAssetsDir);
foreach ($aFiles['files'] as $sFiles) {
if (!in_array($sFiles, $aLockedFiles)) {
unlink($sFiles);
}
}
foreach (array_reverse($aFiles['dirs']) as $sDir) {
if (!util::dirHasFiles($sDir)) {
files::deltree($sDir);
}
}
return true;
}
示例3: getRootDirs
/**
* Root directories
*
* Returns an array of directory under {@link $root} directory.
*
* @uses fileItem
* @return array
*/
public function getRootDirs()
{
$d = files::getDirList($this->root);
$dir = array();
foreach ($d['dirs'] as $v) {
$dir[] = new fileItem($v, $this->root, $this->root_url);
}
return $dir;
}
示例4: makePackage
function makePackage($name, $dir, $remove_path = '', $gzip = true)
{
if ($gzip && !function_exists('gzcompress')) {
return false;
}
if (($filelist = files::getDirList($dir)) === false) {
return false;
}
$res = array('name' => $name, 'dirs' => array(), 'files' => array());
foreach ($filelist['dirs'] as $v) {
$res['dirs'][] = preg_replace('/^' . preg_quote($remove_path, '/') . '/', '', $v);
}
foreach ($filelist['files'] as $v) {
$f_content = base64_encode(file_get_contents($v));
$v = preg_replace('/^' . preg_quote($remove_path, '/') . '/', '', $v);
$res['files'][$v] = $f_content;
}
$res = serialize($res);
if ($gzip) {
$res = gzencode($res);
}
return $res;
}