本文整理汇总了PHP中FileUtil::trimFileList方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::trimFileList方法的具体用法?PHP FileUtil::trimFileList怎么用?PHP FileUtil::trimFileList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::trimFileList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trimFileList
static function trimFileList(&$list)
{
// Consider each child...
foreach ($list as $k => $v) {
// Only consider folders...
if (!is_array($v)) {
continue;
}
// If child has only one child, then collapse it
reset($v);
if (count($v) == 1 && is_array(current($v))) {
//echo("Trying to collapse $k\n");
$list[$k] = current($v);
// Reset our walk through the list...
reset($list);
}
}
// Now recurse on all children.
foreach ($list as $k => $v) {
// Only consider folders...
if (!is_array($v)) {
continue;
}
FileUtil::trimFileList(&$list[$k]);
}
}
示例2: generateFileList
function generateFileList(&$projectFiles, $outputName, &$output)
{
$projName = $this->name;
$projectFiles[$projName] = array();
foreach ($this->dir_list as $dir) {
$dir = FileUtil::normalizeSlashes($dir);
// Build the path.
if (FileUtil::isAbsolutePath($dir)) {
$curPath = $dir;
} else {
$curPath = FileUtil::collapsePath($output->base_dir . $dir);
}
$pathWalk =& $projectFiles[$projName];
if (T3D_Generator::$absPath) {
if (stristr($curPath, getEngineSrcDir()) || stristr($curPath, getLibSrcDir())) {
$curPath = T3D_Generator::$absPath . "/" . str_replace("../", "", $curPath);
}
}
// Check if its a file or a directory.
// If its a file just add it directly and build a containng filter/folder structure,
// for it else if a dir add all files in it.
if (is_file($curPath)) {
// Get the file name
$curFile = basename($curPath);
$curPath = dirname($curPath);
//echo( "FILE: " . $curFile . " PATH: " . $curPath . "\n" );
}
if (is_dir($curPath)) {
//echo( "DIR: " . $curPath . "\n" );
// Get the array we'll be adding things to...
$pathParts = explode('/', FileUtil::collapsePath($dir));
foreach ($pathParts as $part) {
// Skip parts that are relative paths - only want meaningful directories.
if ($part == '..') {
continue;
}
if (!is_array($pathWalk[$part])) {
$pathWalk[$part] = array();
}
$pathWalk =& $pathWalk[$part];
}
// Open directory.
//echo( "SCANNING: " . $curPath . "\n");
$dirHdl = opendir($curPath);
if (!$dirHdl) {
echo "Path " . $curPath . " not found, giving up.\n";
return false;
}
// Iterate over all the files in the path if not a single file spec.
if (!$curFile) {
while ($curFile = readdir($dirHdl)) {
// Skip out if it's an uninteresting dir...
if ($curFile == '.' || $curFile == '..' || $curFile == '.svn' || $curFile == 'CVS') {
continue;
}
$newEntry = $this->createFileEntry($output, $curPath, $curFile);
if ($newEntry) {
$pathWalk[] = $newEntry;
}
}
} else {
$newEntry = $this->createFileEntry($output, $curPath, $curFile);
if ($newEntry) {
$pathWalk = $newEntry;
}
$curFile = '';
}
// Clean up after ourselves!
closedir($dirHdl);
}
}
FileUtil::trimFileList($projectFiles);
// Uncomment me to see the structure the file lister is returning.
//print_r($projectFiles);
return true;
}