def open(self, inf, psw):
        """Return stream object for file data."""

        if inf.file_redir:
            # cannot leave to unrar as it expects copied file to exist
            if inf.file_redir[0] in (RAR5_XREDIR_FILE_COPY, RAR5_XREDIR_HARD_LINK):
                inf = self.getinfo(inf.file_redir[2])
                if not inf:
                    raise BadRarFile('cannot find copied file')

        if inf.flags & RAR_FILE_SPLIT_BEFORE:
            raise NeedFirstVolume("Partial file, please start from first volume: " + inf.filename)

        # is temp write usable?
        use_hack = 1
        if not self._main:
            use_hack = 0
        elif self._main._must_disable_hack():
            use_hack = 0
        elif inf._must_disable_hack():
            use_hack = 0
        elif is_filelike(self._rarfile):
            pass
        elif inf.file_size > HACK_SIZE_LIMIT:
            use_hack = 0
        elif not USE_EXTRACT_HACK:
            use_hack = 0

        # now extract
        if inf.compress_type == RAR_M0 and (inf.flags & RAR_FILE_PASSWORD) == 0 and inf.file_redir is None:
            return self._open_clear(inf)
        elif use_hack:
            return self._open_hack(inf, psw)
        elif is_filelike(self._rarfile):
            return self._open_unrar_membuf(self._rarfile, inf, psw)
        else:
            return self._open_unrar(self._rarfile, inf, psw)
Return stream object for file data.