public function stream_truncate($new_size)
    {
        if ($this->isReadOnly) {
            return false;
        }
        $this->needsFlush = true;
        $this->ensureWritableHandle();

        return ftruncate($this->handle, $new_size);
    }