Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function rmdir($path)
 {
     $this->reactor->addRef();
     $promisor = new Deferred();
     \uv_fs_rmdir($this->loop, $path, function ($fh) use($promisor, $path) {
         $this->reactor->delRef();
         StatCache::clear($path);
         $promisor->succeed((bool) $fh);
     });
     return $promisor->promise();
 }
Ejemplo n.º 2
0
 private function onRmdir($data, $result, $req)
 {
     list($promisor, $path) = $data;
     \call_user_func($this->incrementor, -1);
     if ($result === -1) {
         $promisor->fail(new FilesystemException(\eio_get_last_error($req)));
     } else {
         StatCache::clear($path);
         $promisor->succeed(true);
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function rmdir($path)
 {
     StatCache::clear($path);
     return new Success((bool) @\rmdir($path));
 }
Ejemplo n.º 4
0
 private function onWrite($op, $result, $req)
 {
     $this->isActive = false;
     \call_user_func($this->incrementor, -1);
     if ($result === -1) {
         $op->promisor->fail(new FilesystemException(\eio_get_last_error($req)));
     } else {
         StatCache::clear($this->path);
         $bytesWritten = \strlen($op->writeData);
         $this->pendingWriteOps--;
         $newPosition = $op->position + $bytesWritten;
         $delta = $newPosition - $this->position;
         $this->position = $this->mode[0] === "a" ? $this->position : $newPosition;
         $this->size += $delta;
         $op->promisor->succeed($result);
     }
     if ($this->queue) {
         $this->dequeue();
     }
 }
Ejemplo n.º 5
0
 private function doWrite($op)
 {
     $this->reactor->addRef();
     $onWrite = function ($fh, $result) use($op) {
         $this->isActive = false;
         $this->reactor->delRef();
         if ($result < 0) {
             $op->promisor->fail(new FilesystemException(\uv_strerror($result)));
         } else {
             StatCache::clear($this->path);
             $bytesWritten = \strlen($op->writeData);
             $this->pendingWriteOps--;
             $newPosition = $op->position + $bytesWritten;
             $delta = $newPosition - $this->position;
             $this->position = $this->mode[0] === "a" ? $this->position : $newPosition;
             $this->size += $delta;
             $op->promisor->succeed($result);
         }
         if ($this->queue) {
             $this->dequeue();
         }
     };
     \uv_fs_write($this->loop, $this->fh, $op->writeData, $op->position, $onWrite);
 }