final public function ls($path, $exclude = array(".DS_Store", ".git", ".svn", ".CVS"), $recursive = FALSE, $recursivelimit = 0, $showfiles = FALSE, $sort = TRUE, $long = FALSE)
    {

        //1. Search $name as a folder or as a file
        if (!$this->is($path)) { //if in path is a directory
            return array();
        }

        $dirh = @opendir($path); //directory handler
//$recursion  = 0;
        $found = [];

        if ($dirh) {
            while (false !== ($file = readdir($dirh))) {
                // remove '.' and '..'
                if ($file == '.' || $file == '..' || in_array($file, $exclude)) {
                    continue;
                }

                $recursion = 0;
                $newPath = $path . $file;

                if ($this->isFolder($newPath) && $recursive && ($recursion < $recursiveLimit)) {
                    //echo $this->is($newPath)."<br />";
                    //echo $newPath."<br />";
                    $newRecursiveLimit = ((int)$recursiveLimit > 0) ? ((int)$recursiveLimit - 1) : 0;
                    $items = $this->list($newPath, $exclude, $recursive, $newRecursiveLimit);
                    $found = array_merge($items, $found);
                }

                $found[] = $newPath;
            }
            closedir($dirh);
        }

//@TODO if long, get additional info for each path;

        return $found;
    }
final public function ls($path, $exclude = array(".DS_Store", ".git", ".svn", ".CVS"), $recursive = FALSE, $recursivelimit = 0, $showfiles = FALSE, $sort = TRUE, $long = FALSE)
    {

        //1. Search $name as a folder or as a file
        if (!$this->is($path)) { //if in path is a directory
            return array();
        }

        $dirh = @opendir($path); //directory handler
//$recursion  = 0;
        $found = [];

        if ($dirh) {
            while (false !== ($file = readdir($dirh))) {
                // remove '.' and '..'
                if ($file == '.' || $file == '..' || in_array($file, $exclude)) {
                    continue;
                }

                $recursion = 0;
                $newPath = $path . $file;

                if ($this->isFolder($newPath) && $recursive && ($recursion < $recursiveLimit)) {
                    //echo $this->is($newPath)."<br />";
                    //echo $newPath."<br />";
                    $newRecursiveLimit = ((int)$recursiveLimit > 0) ? ((int)$recursiveLimit - 1) : 0;
                    $items = $this->list($newPath, $exclude, $recursive, $newRecursiveLimit);
                    $found = array_merge($items, $found);
                }

                $found[] = $newPath;
            }
            closedir($dirh);
        }

//@TODO if long, get additional info for each path;

        return $found;
    }
final public function ls ( $ path , $ exclude = array ( ".DS_Store" , ".git" , ".svn" , ".CVS" ) , $ recursive = FALSE , $ recursivelimit = 0 , $ showfiles = FALSE , $ sort = TRUE , $ long = FALSE ) { //1. Search $name as a folder or as a file if ( ! $ this -> is ( $ path ) ) { //if in path is a directory return array ( ) ; } $ dirh = @ opendir ( $ path ) ; //directory handler //$recursion  = 0; $ found = [ ] ; if ( $ dirh ) { while ( false !== ( $ file = readdir ( $ dirh ) ) ) { // remove '.' and '..' if ( $ file == '.' || $ file == '..' || in_array ( $ file , $ exclude ) ) { continue ; } $ recursion = 0 ; $ newPath = $ path . $ file ; if ( $ this -> isFolder ( $ newPath ) && $ recursive && ( $ recursion < $ recursiveLimit ) ) { //echo $this->is($newPath)."<br />"; //echo $newPath."<br />"; $ newRecursiveLimit = ( ( int ) $ recursiveLimit > 0 ) ? ( ( int ) $ recursiveLimit - 1 ) : 0 ; $ items = $ this -> list ( $ newPath , $ exclude , $ recursive , $ newRecursiveLimit ) ; $ found = array_merge ( $ items , $ found ) ; } $ found [ ] = $ newPath ; } closedir ( $ dirh ) ; } //@TODO if long, get additional info for each path; return $ found ; }
Lists all the files in a directory

@param string $path the compound path being searched and listed
@param array $exclude a list of folders, files or fileTypes to exclude from the list
@param boolean $recursive Determines whether to search subdirectories if found
@param interger $recursivelimit The number of deep subfolder levels to search
@param boolean $showfiles Include Files contained in each folder to the array
@param boolean $sort Sort folder/files in alphabetical order
@param boolean $long returns size, permission, datemodified in list if true, Slow!!

@return array $list = array(
"path/to/folder" => array(
"name" => '',
"parent" => '', //only in long
"size" => '', //only in long
"modified" => '', //only in long
"permission" => '',
"files" => array(
"path/to/file" => array(
"name" => '',
"size" => '', //only in long
"modified" => '', //only in long
"permission" => '',
"extension"  => '',
"mimetype"   => ''//only in long
)
),
"children" => array()
Lists all the files in a directory