/** * {@inheritdoc} */ public function stat($path) { if ($stat = StatCache::get($path)) { return new Success($stat); } elseif ($stat = @\stat($path)) { StatCache::set($path, $stat); \clearstatcache(true, $path); } else { $stat = null; } return new Success($stat); }
/** * {@inheritdoc} */ public function stat($path) { if ($stat = StatCache::get($path)) { return new Success($stat); } $this->reactor->addRef(); $promisor = new Deferred(); \uv_fs_stat($this->loop, $path, function ($fh, $stat) use($promisor, $path) { if (empty($fh)) { $stat = null; } else { StatCache::set($path, $stat); } $this->reactor->delRef(); $promisor->succeed($stat); }); return $promisor->promise(); }
private function onStat($data, $result, $req) { list($promisor, $path) = $data; \call_user_func($this->incrementor, -1); if ($result === -1) { $promisor->succeed(null); } else { StatCache::set($path, $result); $promisor->succeed($result); } }