/** * {@inheritdoc} */ public function scandir($path) { $this->incrementPending(); $promisor = new Deferred(); $flags = \EIO_READDIR_STAT_ORDER | \EIO_READDIR_DIRS_FIRST; $priority = \EIO_PRI_DEFAULT; \eio_readdir($path, $flags, $priority, [$this, "onScandir"], $promisor); return $promisor->promise(); }
/** * {@inheritdoc} */ public function lsDir(string $path) : \Generator { $delayed = new Delayed(); \eio_readdir($path, 0, null, function (Delayed $delayed, $result, $req) { if (-1 === $result) { $delayed->reject(new FileException(sprintf('Could not read directory: %s.', \eio_get_last_error($req)))); } else { $result = $result['names']; sort($result, \SORT_STRING | \SORT_NATURAL | \SORT_FLAG_CASE); $delayed->resolve($result); } }, $delayed); $this->poll->listen(); try { $result = (yield $delayed); } finally { $this->poll->done(); } return $result; }
/** * Readdir() * @param string $path Path * @param callable $cb Callback * @param integer $flags Flags * @param integer $pri Priority * @return resource|true */ public static function readdir($path, $cb = null, $flags, $pri = EIO_PRI_DEFAULT) { $cb = CallbackWrapper::forceWrap($cb); if (!FileSystem::$supported) { $r = glob($path); if ($cb) { call_user_func($cb, $path, $r); } return true; } return eio_readdir($path, $flags, $pri, $cb, $path); }
public static function readdir($path, $cb = null, $flags, $pri = EIO_PRI_DEFAULT) { if (!FS::$supported) { $r = glob($path); if ($cb) { call_user_func($cb, $path, $r); } return; } return eio_readdir($path, $flags, $pri, $cb, $path); }