Example #1
0
 /**
  * Rename
  * @param  string   $path    Path
  * @param  string   $newpath New path
  * @param  callable $cb      Callback
  * @param  integer  $pri     Priority
  * @return resource|boolean
  */
 public static function rename($path, $newpath, $cb = null, $pri = EIO_PRI_DEFAULT)
 {
     $cb = CallbackWrapper::forceWrap($cb);
     if (!self::$supported) {
         $r = rename($path, $newpath);
         if ($cb) {
             call_user_func($cb, $path, $newpath, $r);
         }
         return $r;
     }
     return eio_rename($path, $newpath, $pri, $cb, $path);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function rename($from, $to)
 {
     $this->incrementPending();
     $promisor = new Deferred();
     $priority = \EIO_PRI_DEFAULT;
     \eio_rename($from, $to, $priority, [$this, "onGenericResult"], $promisor);
     return $promisor->promise();
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function rename(string $oldPath, string $newPath) : \Generator
 {
     $delayed = new Delayed();
     \eio_rename($oldPath, $newPath, null, function (Delayed $delayed, $result, $req) {
         if (-1 === $result) {
             $delayed->reject(new FileException(sprintf('Renaming the file failed: %s.', \eio_get_last_error($req))));
         } else {
             $delayed->resolve(true);
         }
     }, $delayed);
     $this->poll->listen();
     try {
         $result = (yield $delayed);
     } finally {
         $this->poll->done();
     }
     return $result;
 }