2020-01-01 13:17:19 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace League\Flysystem\Adapter;
|
|
|
|
|
|
|
|
class Ftpd extends Ftp
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function getMetadata($path)
|
|
|
|
{
|
|
|
|
if ($path === '') {
|
|
|
|
return ['type' => 'dir', 'path' => ''];
|
|
|
|
}
|
2020-09-20 15:14:34 +08:00
|
|
|
|
2020-01-01 13:17:19 +08:00
|
|
|
if (@ftp_chdir($this->getConnection(), $path) === true) {
|
|
|
|
$this->setConnectionRoot();
|
|
|
|
|
|
|
|
return ['type' => 'dir', 'path' => $path];
|
|
|
|
}
|
|
|
|
|
2020-09-20 15:14:34 +08:00
|
|
|
$object = ftp_raw($this->getConnection(), 'STAT ' . $this->escapePath($path));
|
|
|
|
|
|
|
|
if ( ! $object || count($object) < 3) {
|
2020-01-01 13:17:19 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (substr($object[1], 0, 5) === "ftpd:") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->normalizeObject($object[1], '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
protected function listDirectoryContents($directory, $recursive = true)
|
|
|
|
{
|
2020-09-20 15:14:34 +08:00
|
|
|
$listing = ftp_rawlist($this->getConnection(), $this->escapePath($directory), $recursive);
|
2020-01-01 13:17:19 +08:00
|
|
|
|
|
|
|
if ($listing === false || ( ! empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->normalizeListing($listing, $directory);
|
|
|
|
}
|
|
|
|
}
|