| 1 |
<?php |
| 2 |
|
| 3 |
namespace League\Flysystem\Adapter; |
| 4 |
|
| 5 |
class Ftpd extends Ftp |
| 6 |
{ |
| 7 |
/** |
| 8 |
* @inheritdoc |
| 9 |
*/ |
| 10 |
public function getMetadata($path) |
| 11 |
{ |
| 12 |
if ($path === '') { |
| 13 |
return ['type' => 'dir', 'path' => '']; |
| 14 |
} |
| 15 |
|
| 16 |
if (@ftp_chdir($this->getConnection(), $path) === true) { |
| 17 |
$this->setConnectionRoot(); |
| 18 |
|
| 19 |
return ['type' => 'dir', 'path' => $path]; |
| 20 |
} |
| 21 |
|
| 22 |
$object = ftp_raw($this->getConnection(), 'STAT ' . $this->escapePath($path)); |
| 23 |
|
| 24 |
if ( ! $object || count($object) < 3) { |
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
if (substr($object[1], 0, 5) === "ftpd:") { |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
return $this->normalizeObject($object[1], ''); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* @inheritdoc |
| 37 |
*/ |
| 38 |
protected function listDirectoryContents($directory, $recursive = true) |
| 39 |
{ |
| 40 |
$listing = ftp_rawlist($this->getConnection(), $this->escapePath($directory), $recursive); |
| 41 |
|
| 42 |
if ($listing === false || ( ! empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) { |
| 43 |
return []; |
| 44 |
} |
| 45 |
|
| 46 |
return $this->normalizeListing($listing, $directory); |
| 47 |
} |
| 48 |
} |
| 49 |
|