<?php
/*
Copyright (C) 2001-2004 ZZOSS GbR, http://www.zzoss.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
@version $Id: Find.php,v 1.2 2004/03/15 09:51:24 ordnas Exp $
@copyright Copyright © 2001-2004 ZZ/OSS GbR, http://www.zzoss.com
@license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
*/
require_once 'File/Find.php';
class ZZOSS_FileFind extends File_Find
{
var $filelist = array();
var $filepath = array();
var $filterDirs = array();
var $filterFiles = NULL;
var $prefix = NULL;
function setFilterDirs($filterDirs)
{
$this->filterDirs = $filterDirs;
}
function setFilterFiles($filterFiles)
{
$this->filterFiles = $filterFiles;
}
function setPrefix($prefix)
{
$this->prefix = $prefix;
}
function listFiles($dir, $maxrecursion = 0)
{
$map = File_Find::mapTreemultiple($dir, $maxrecursion);
$this->map2List($map);
return $this->filelist;
}
function map2List($map, $level = 0)
{
if(!isset($this->filepath[$level])){
$this->filepath[$level] = '';
}
foreach($map as $id => $file){
if(is_numeric($id)){
if(!preg_match($this->filterFiles, $file)){
$this->filelist[] = $this->prefix.$this->filepath[$level].$file;
}
} else {
if(!in_array($id, $this->filterDirs)){
if(isset($this->filepath[$level])){
$this->filepath[$level+1] = $this->filepath[$level].$id.DIRECTORY_SEPARATOR;
}
ZZOSS_FileFind::map2List($file, $level+1);
}
}
}
unset($this->filepath[$level]);
return true;
}
}
?>