File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/zipstream.cpython-310.pyc
o
�b�% � @ s� d Z ddlZddlZddlZddlZG dd� dej�ZG dd� d�ZG dd� de�Z G d d
� d
e�Z
dZdd
� Zdd� Z
ddd�ZdS )z�
An incremental approach to unzipping files. This allows you to unzip a little
bit of a file at a time, which means you can report progress as a file unzips.
� Nc @ s e Zd ZdZdd� ZdS )�ChunkingZipFilez~
A L{zipfile.ZipFile} object which, with L{readfile}, also gives you access
to a file-like object for each entry.
c C s" | j dvr td��| jstd��| �|�}| j�|jd� | j�tj�}|dd� tj kr2t�
d��t�tj
|�}| j�|tj �}|tj rP| j�|tj � |jd@ r[|�d�}n|�d �}||jkrot�
d
|j|f ��|jtjkr{t| |j�S |jtjkr�t| |j�S t�
d|j|f ��)z3
Return file-like object for name.
)�r�azread() requires mode "r" or "a"z3Attempt to read ZIP archive that was already closedr � z Bad magic number for file headeri zutf-8�cp437z3File name in directory "%s" and header "%s" differ.z-Unsupported compression method %d for file %s)�mode�RuntimeError�fp�getinfo�seek�
header_offset�read�zipfile�sizeFileHeader�stringFileHeader�
BadZipfile�struct�unpack�structFileHeader�_FH_FILENAME_LENGTH�_FH_EXTRA_FIELD_LENGTH� flag_bits�decode�
orig_filename�
compress_type�
ZIP_STORED�ZipFileEntry�
compress_size�ZIP_DEFLATED�DeflatedZipFileEntry)�self�name�zinfo�fheader�fname� fname_str� r&