/** * Map the directory tree given by the directory_path parameter. * * @param string $directory contains the directory path that you * want to map. * * @return array a two element array, the first element containing a list * of all the directories, the second element containing a list of all the * files. * * @author Sterling Hughes <*****@*****.**> * @access public */ function &maptree($directory) { /* if called statically */ if (!isset($this) || !is_a($this, "File_Find")) { $obj = new File_Find(); return $obj->maptree($directory); } /* clear the results just in case */ $this->files = array(); $this->directories = array(); /* strip out trailing slashes */ $directory = preg_replace('![\\\\/]+$!', '', $directory); $this->_dirs = array($directory); while (count($this->_dirs)) { $dir = array_pop($this->_dirs); File_Find::_build($dir, $this->dirsep); array_push($this->directories, $dir); } sort($this->directories); sort($this->files); $retval = array($this->directories, $this->files); return $retval; }
/** * Map the directory tree given by the directory_path parameter. * * @param string $directory contains the directory path that you * want to map. * * @return array a two element array, the first element containing a list * of all the directories, the second element containing a list of all the * files. * * @author Sterling Hughes <*****@*****.**> * @access public */ function &maptree($directory) { /* if called statically */ if (!isset($this) || !is_a($this, "File_Find")) { $obj =& new File_Find(); return $obj->maptree($directory); } /* clear the results just in case */ $this->files = array(); $this->directories = array(); /* consistency rules - strip out trailing slashes */ $directory = preg_replace('![\\\\/]+$!', '', $directory); /* use only native system directory delimiters */ $directory = preg_replace("![\\\\/]+!", DIRECTORY_SEPARATOR, $directory); $this->_dirs = array($directory); while (count($this->_dirs)) { $dir = array_pop($this->_dirs); File_Find::_build($dir); array_push($this->directories, $dir); } return array($this->directories, $this->files); }
/** * Map the directory tree given by the directory_path parameter. * * @param string $directory contains the directory path that you * want to map. * * @return array a two element array, the first element containing a list * of all the directories, the second element containing a list of all the * files. * * @author Sterling Hughes <*****@*****.**> * @access public */ function &maptree($directory) { $this->_dirs = array($directory); while (count($this->_dirs)) { $dir = array_pop($this->_dirs); File_Find::_build($dir); array_push($this->directories, $dir); } return array($this->directories, $this->files); }