public function setMode($mode)
    {
        if (is_resource($this->_stream) && $this->_mode != $mode) {
            $meta = stream_get_meta_data($this->_stream);
            $this->setStream($meta['uri']);
        }

        $this->_mode = $mode;

        return $this;
    }