Ftpd.php 1.1 KB

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