PHPDaemon\FS\File::truncate PHP Méthode

truncate() public méthode

Truncates this file
public truncate ( integer $offset, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$offset integer Offset. Default is 0
$cb callable Callback
$pri integer Priority
Résultat resource | boolean
    public function truncate($offset = 0, $cb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd || $this->fd === -1) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            $fp = fopen($this->path, 'r+');
            $r = $fp && ftruncate($fp, $offset);
            if ($cb) {
                $cb($this, $r);
            }
            return $r;
        }
        return eio_ftruncate($this->fd, $offset, $pri, $cb, $this);
    }