Example #1
0
 /**
  * {@inheritdoc}
  */
 public function symlink($target, $link)
 {
     $this->incrementPending();
     $promisor = new Deferred();
     $priority = \EIO_PRI_DEFAULT;
     \eio_symlink($target, $link, $priority, [$this, "onGenericResult"], $promisor);
     return $promisor->promise();
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 private function doLink(string $source, string $target, bool $hard) : \Generator
 {
     $callback = function (Delayed $delayed, $result, $req) {
         if (-1 === $result) {
             $delayed->reject(new FileException(sprintf('Could not create link: %s.', \eio_get_last_error($req))));
         } else {
             $delayed->resolve(true);
         }
     };
     $delayed = new Delayed();
     if ($hard) {
         \eio_link($source, $target, null, $callback, $delayed);
     } else {
         \eio_symlink($source, $target, null, $callback, $delayed);
     }
     $this->poll->listen();
     try {
         $result = (yield $delayed);
     } finally {
         $this->poll->done();
     }
     return $result;
 }