Returns a list of files and directories stored in the specified channels file repository.

@param  integer $cid
@param  string  $cpw
@param  string  $path
@param  boolean $recursive
@return array
358945
public function channelFileList($cid, $cpw = "", $path = "/", $recursive = FALSE)
  {
    $files = $this->execute("ftgetfilelist", array("cid" => $cid, "cpw" => $cpw, "path" => $path))->toArray();
    $count = count($files);

    for($i = 0; $i < $count; $i++)
    {
      $files[$i]["sid"]  = $this->getId();
      $files[$i]["cid"]  = $files[0]["cid"];
      $files[$i]["path"] = $files[0]["path"];
      $files[$i]["src"]  = new Str($cid ? $files[$i]["path"] : "/");

      if(!$files[$i]["src"]->endsWith("/"))
      {
        $files[$i]["src"]->append("/");
      }

      $files[$i]["src"]->append($files[$i]["name"]);

      if($recursive && $files[$i]["type"] == TeamSpeak3::FILE_TYPE_DIRECTORY)
      {
        $files = array_merge($files, $this->channelFileList($cid, $cpw, $path . $files[$i]["name"], $recursive));
      }
    }

    uasort($files, array(__CLASS__, "sortFileList"));

    return $files;
  }
795048
public function getFiles($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return Filesystem::files((string) $path, $recursive);
            }
        );
    }
1238290
protected function scanDirectory(string $path, string $parentDir): array
    {
        $files = [];

        $rdi = new \RecursiveDirectoryIterator(
            $path,
            \FilesystemIterator::SKIP_DOTS |
            \FilesystemIterator::KEY_AS_FILENAME |
            \FilesystemIterator::CURRENT_AS_FILEINFO
        );

        $rii = new \RecursiveIteratorIterator($rdi);

        $needle = Constants::DS.$parentDir.Constants::DS;
        $len = \strlen($needle);
        foreach ($rii as $fileInfo) {
            $path = $fileInfo->getPathname();
            $pos = \strrpos($path, $needle);
            $files[] = \substr($path, $pos + $len);
        }

        return $files;
    }
379126
public static function glob_recursive( $path ) {
		$files = [];
		if ( preg_match( '/\\' . DIRECTORY_SEPARATOR . 'vendor$/', $path ) ) {
			return $files;
		}

		foreach ( glob( $path . '/*' ) as $file ) {
			if ( is_dir( $file ) ) {
				$files = array_merge( $files, static::glob_recursive( $file ) );
			} elseif ( preg_match( '/\.php$/', $file ) ) {
				$files[] = $file;
			}
		}

		return $files;
	}
1059645
private function scanFolders(string $dir, bool $recursive): array
    {
        $files = [];

        // $dir comes from the database. The actual folder may not exist.
        if (is_dir($dir)) {
            foreach (scandir($dir, SCANDIR_SORT_NONE) as $path) {
                if (is_dir($dir . $path)) {
                    // What if there are user-defined subfolders “thumbs” or “watermarks”?
                    if ($path !== '.' && $path !== '..' && $path !== 'thumbs' && $path !== 'watermark' && $recursive) {
                        foreach ($this->scanFolders($dir . $path . '/', $recursive) as $subpath) {
                            $files[] = $path . '/' . $subpath;
                        }
                    }
                } else {
                    $files[] = $path;
                }
            }
        }

        return $files;
    }
1119465
public function listContents($directory = '', $recursive = false)
    {
        [$filesystem, $directory, $prefix] = $this->getFilesystemAndPath($directory);
        $result = $filesystem->listContents($directory, $recursive);

        foreach ($result as &$file) {
            $file['filesystem'] = $prefix;
        }

        return $result;
    }
1295904
protected function doListContents($directory, $recursive)
	{
		$filter = function ($path) use ($directory, $recursive) {
			// Remove the root directory from any listing.
			if ($path === '') {
				return false;
			}

			if (Util::dirname($path) === $directory) {
				return true;
			}

			return $recursive && $this->pathIsInDirectory($path, $directory);
		};

		return \array_filter(\array_keys($this->storage), $filter);
	}
536500
public function listContents($directory = '', $recursive = false): array
    {
        $result = parent::listContents($directory, $recursive);

        list(, $directory) = $this->getPrefixAndPath($directory);
        $relativePathPos = strlen(trim($directory, '/')) + 1;

        foreach ($result as &$file) {
            $file['relative_path'] = substr($file['path'], $relativePathPos);
        }

        return $result;
    }
226974
public function listContents($path = '/', $recursive = false)
    {
        $contents = $this->getApi()->getTreeMetadata($path, $recursive);

        if ($this->isDirectoryContents($contents) === false) {
            $contents = [];
        }

        return $contents;
    }
814106
public static function rmWorkingCopy($path, $recursive = true)
    {
        $returnValue = (bool) false;

        
		
		if (is_file($path)) {
			if(preg_match('/^\//', $path)){
				$returnValue = @unlink($path);
			}
		} else if ($recursive) {
			if (is_dir($path)) {
				$iterator = new DirectoryIterator($path);
				foreach ($iterator as $fileinfo) {
					if (!$fileinfo->isDot()) {
						self::rmWorkingCopy($fileinfo->getPathname(), true);
					}
					unset($fileinfo);
				}
				unset($iterator);
				$returnValue = @rmdir($path);
			}
		}
						
        

        return (bool) $returnValue;
    }
1355161
public static function files($path, $recursive = false, $pathType = self::PATH_ABSOLUTE)
    {
        $files = [];

        /** @var $file \SplFileInfo */
        foreach (Filesystem::files($path, $recursive) as $file) {
            switch ($pathType) {
                case ($pathType === self::PATH_BASENAME):
                    $name = $file->getBasename();
                    break;

                case ($pathType === static::PATH_RELATIVE):
                    $pathLength = strlen($path);
                    $name = $file->getRealPath();
                    $name = trim(substr($name, $pathLength), DIRECTORY_SEPARATOR);
                    break;

                case ($pathType === static::PATH_ABSOLUTE):
                default:
                    $name = $file->getPathname();
                    break;
            }

            $files[] = $name;
        }

        return $files;
    }
955985
protected function listDirectoryContents($directory, $recursive = true)
    {
        $result = [];
        $connection = $this->getConnection();
        $location = $this->prefix($directory);
        $listing = $connection->rawlist($location);

        if ($listing === false) {
            return [];
        }

        foreach ($listing as $filename => $object) {
            if (in_array($filename, ['.', '..'])) {
                continue;
            }

            $path = empty($directory) ? $filename : ($directory.'/'.$filename);
            $result[] = $this->normalizeListingObject($path, $object);

            if ($recursive && isset($object['type']) && $object['type'] === NET_SFTP_TYPE_DIRECTORY) {
                $result = array_merge($result, $this->listDirectoryContents($path));
            }
        }

        return $result;
    }
83031
public function getDirectoryFiles(string $path, string $postfix = '')
    {
        if (!is_dir($path)) {
            return [];
        }

        $results = [];
        $files   = array_diff(scandir($path), ['..', '.']);
        foreach ($files as $file) {
            $absolutePath = $path.DIRECTORY_SEPARATOR.$file;
            if (!is_dir($absolutePath) && empty($postfix) || Str::endsWith($file, $postfix)) {
                $results[] = $absolutePath;
            }
        }

        return $results;
    }
1067808
public function listWith(array $keys = [], $directory = '', $recursive = false)
    {
        $contents = $this->listContents($directory, $recursive);

        foreach ($contents as $index => $object) {
            if ($object['type'] === 'file') {
                $missingKeys = \array_diff($keys, \array_keys($object));
                $contents[$index] = \array_reduce($missingKeys, [$this, 'getMetadataByName'], $object);
            }
        }

        return $contents;
    }
894374
function recursiveReaddirSync(path) {
  var list = []
    , files = fs.readdirSync(path)
    , stats
    ;

  files.forEach(function (file) {
    stats = fs.lstatSync(p.join(path, file));
    if(stats.isDirectory()) {
      list = list.concat(recursiveReaddirSync(p.join(path, file)));
    } else {
      list.push(p.join(path, file));
    }
  });

  return list;
}
667278
public function directories($directory = null, $recursive = false)
    {

        $directories = [ ];

        foreach (Finder::create()->in($directory)->directories() as $dir) {
            $directories[] = $dir->getPathname();
        }

        return $directories;
    }
327749
public static function dirs($path, $recursive = false, $toArray = false, $pathType = self::PATH_ABSOLUTE)
	{
		/**
		 * Files callback
		 *
		 * @param \SplFileInfo                $current  Current item's value
		 * @param string                      $key      Current item's key
		 * @param \RecursiveDirectoryIterator $iterator Iterator being filtered
		 *
		 * @return boolean   TRUE to accept the current item, FALSE otherwise
		 */
		$callback = function ($current, $key, $iterator) use ($path, $recursive)
		{
			if ($recursive)
			{
				// Ignore self
				if ($iterator->getRealPath() == static::cleanPath($path))
				{
					return false;
				}

				// If set to recursive, every returned folder name will include a dot (.),
				// so we can't using isDot() to detect folder.
				return $iterator->isDir() && ($iterator->getBasename() != '..');
			}
			else
			{
				return $iterator->isDir() && !$iterator->isDot();
			}
		};

		$files = static::findByCallback($path, $callback, $recursive);
		
		if ($toArray) {
		    $files = static::toArray($files, $pathType);
		}
	    
	    return $files;
	}