Exemple #1
0
 /**
  * @coroutine
  *
  * @param int $uid
  * @param int $gid
  *
  * @return \Generator
  *
  * @resolve bool
  *
  * @throws \Icicle\File\Exception\FileException
  */
 private function chowngrp(int $uid, int $gid) : \Generator
 {
     if (!$this->isOpen()) {
         throw new FileException('The file has been closed.');
     }
     $delayed = new Delayed();
     \eio_fchown($this->handle, $uid, $gid, null, function (Delayed $delayed, $result, $req) {
         if (-1 === $result) {
             $delayed->reject(new FileException(sprintf('Changing the file owner or group 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;
 }
Exemple #2
0
 /**
  * Changes ownership of this file
  * @param  integer $uid User ID
  * @param  integer $gid Group ID
  * @param  callable $cb = null Callback
  * @param  integer $pri = EIO_PRI_DEFAULT Priority
  * @return resource|false
  */
 public function chown($uid, $gid = -1, $cb = null, $pri = EIO_PRI_DEFAULT)
 {
     $cb = CallbackWrapper::forceWrap($cb);
     if (!$this->fd) {
         if ($cb) {
             $cb($this, false);
         }
         return false;
     }
     if (!FileSystem::$supported) {
         $r = chown($this->path, $uid);
         if ($gid !== -1) {
             $r = $r && chgrp($this->path, $gid);
         }
         if ($cb) {
             $cb($this, $r);
         }
         return false;
     }
     return eio_fchown($this->fd, $uid, $gid, $pri, $cb, $this);
 }
Exemple #3
0
 public function chown($uid, $gid = -1, $cb, $pri = EIO_PRI_DEFAULT)
 {
     if (!FS::$supported) {
         $r = chown($path, $uid);
         if ($gid !== -1) {
             $r = $r && chgrp($path, $gid);
         }
         if ($cb) {
             call_user_func($cb, $this, $r);
         }
         return;
     }
     return eio_fchown($this->fd, $uid, $gid, $pri, $cb, $this);
 }