示例#1
0
文件: UvDriver.php 项目: staabm/file
 /**
  * {@inheritdoc}
  */
 public function stat($path)
 {
     $this->reactor->addRef();
     $promisor = new Deferred();
     \uv_fs_stat($this->loop, $path, function ($fh, $stat) use($promisor) {
         if ($fh) {
             $stat["isdir"] = (bool) ($stat["mode"] & \UV::S_IFDIR);
             $stat["isfile"] = empty($stat["isdir"]);
         } else {
             $stat = null;
         }
         $this->reactor->delRef();
         $promisor->succeed($stat);
     });
     return $promisor->promise();
 }
示例#2
0
文件: stat.php 项目: zhanglei/php-uv
<?php

uv_fs_stat(uv_default_loop(), __FILE__, function ($result, $da) {
    var_dump($da);
});
uv_run();
示例#3
0
 /**
  * {@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();
 }
 /**
  * @todo
  * @param string $path
  * @param callable $callback
  * @return $this
  */
 public function stat($path, callable $callback = null)
 {
     $self = $this;
     \uv_fs_stat($this->getLoop()->getBackend(), $path, function ($fd) use($callback, $self) {
         $callback($self, $fd);
     });
     return $this;
 }