/**
* List directory content
*
* @param string $path
* @return boolean
*/
public function ls($path = null)
{
$path = "{$this->_location}/{$path}";
if (is_dir($path)) {
$directory = new DirectoryIterator($path);
} else {
return false;
}
$collection = new Collection();
foreach ($directory as $d) {
if ($d->isDot()) {
continue;
}
$url = rtrim($this->_config['url'], '/');
$path = rtrim(substr($d->getPath(), strlen($this->_location)), '/') . '/';
if ($url) {
$url .= "{$path}{$d->getFilename()}";
}
$collection->append(new Entity(array('name' => $d->getFilename(), 'dir' => $d->isDir(), 'url' => $url, 'path' => $path, 'size' => $d->isDir() ? null : $d->getSize(), 'mode' => substr(sprintf('%o', $d->getPerms()), -4), 'adapter' => $this)));
}
return $collection;
}