Ë
    F^(h¾  ã                   ó:  — d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
Z
d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ  eeeeee«      Z ej                  dej,                  egeej.                  «      Z eed	«      Zed
d
ej6                  fd„«       Z G d„ de«      Zy)é    )Úcontextmanager)Ú	CFUNCTYPEÚPOINTERÚc_intÚ
c_longlongÚc_void_pÚcastÚcreate_string_bufferN)Ú
open_files)ÚAbstractArchiveFileSystem)Ú
MemoryFile)ÚDEFAULT_BLOCK_SIZEÚread_set_seek_callbackÚ
NO_OPEN_CBÚallc              #   ó˜  ‡ ‡‡K  — t        |«      Št        ‰t        «      Šˆˆˆ fd„}ˆ fd„}t        j                  |«      }t        |«      }t        r!t        j                  }t        j                  }	nZt        j                  j                  t        j                  «      }t        j                  j                  t        j                  «      }	t        j                  j                  ||«      5 }
t        |
|«       t        j                   |
d|||	«       t        j                  j#                  |
«      –— ddd«       y# 1 sw Y   yxY w­w)z†Read an archive from a seekable file-like object.

    The `file` object must support the standard `readinto` and 'seek' methods.
    c                 óf   •— ‰j                  ‰«      }t        |t        t        «      «      }‰|d<   |S )Nr   )Úreadintor	   r   r   )Ú	archive_pÚcontextÚptrptrÚlengthÚbufÚbuf_pÚfiles       €€€ú_/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fsspec/implementations/libarchive.pyÚ	read_funcz custom_reader.<locals>.read_func*   s0   ø€ à—‘˜sÓ#ˆä�fœg¤hÓ/Ó0ˆØˆˆq‰	àˆó    c                 óH   •— ‰j                  ||«       ‰j                  «       S )N)ÚseekÚtell)r   r   ÚoffsetÚwhencer   s       €r   Ú	seek_funcz custom_reader.<locals>.seek_func3   s   ø€ Ø�	‰	�&˜&Ô!à�y‰y‹{Ðr   N)r
   r	   r   ÚffiÚREAD_CALLBACKÚSEEK_CALLBACKÚnew_apir   ÚNO_CLOSE_CBÚ
libarchiveÚreadÚOPEN_CALLBACKÚVOID_CBÚCLOSE_CALLBACKÚnew_archive_readr   Ú	read_openÚArchiveRead)r   Úformat_nameÚfilter_nameÚ
block_sizer   r$   Úread_cbÚseek_cbÚopen_cbÚclose_cbr   r   r   s   `          @@r   Úcustom_readerr9   !   sç   úè ø€ ô ˜zÓ
*€CÜ�”hÓ€Eöôô
 ×Ñ 	Ó*€GÜ˜IÓ&€GåÜ—.‘.ˆÜ—?‘?‰ä—/‘/×/Ñ/´·±Ó<ˆÜ—?‘?×1Ñ1´#·+±+Ó>ˆä	�‰×	)Ñ	)¨+°{Ó	Cð 5ÀyÜ˜y¨'Ô2Ü�‰�i  w°¸ÔBÜ�o‰o×)Ñ)¨)Ó4Ò4÷5÷ 5ñ 5üs   …C)E
Ã.AD>Ä5	E
Ä>EÅE
c                   ót   ‡ — e Zd ZdZdZdZdZddddefˆ fd„	Ze	d„ «       Z
eˆ fd	„«       Zd
„ Z	 	 	 	 dd„Zˆ xZS )ÚLibArchiveFileSystemay  Compressed archives as a file-system (read-only)

    Supports the following formats:
    tar, pax , cpio, ISO9660, zip, mtree, shar, ar, raw, xar, lha/lzh, rar
    Microsoft CAB, 7-Zip, WARC

    See the libarchive documentation for further restrictions.
    https://www.libarchive.org/

    Keeps file object open while instance lives. It only works in seekable
    file-like objects. In case the filesystem does not support this kind of
    file object, it is recommended to cache locally.

    This class is pickleable, but not necessarily thread-safe (depends on the
    platform). See libarchive documentation for details.
    Ú r*   FÚrNc                 ó(  •— t        ‰| �  | fi |¤Ž |dk7  rt        d«      ‚t        |t        «      r7t        |fd|i|xs i ¤Ž}t        |«      dk7  rt        d|› d|› d�«      ‚|d   }|| _        |j                  «       | _	        || _
        d	| _        y	)
aB  
        Parameters
        ----------
        fo: str or file-like
            Contains ZIP, and must exist. If a str, will fetch file using
            :meth:`~fsspec.open_files`, which must return one file exactly.
        mode: str
            Currently, only 'r' accepted
        target_protocol: str (optional)
            If ``fo`` is a string, this value can be used to override the
            FS protocol inferred from a URL
        target_options: dict (optional)
            Kwargs passed when instantiating the target FS, if ``fo`` is
            a string.
        r=   z%Only read from archive files acceptedÚprotocolé   zPath "z(" did not resolve to exactly one file: "ú"r   N)ÚsuperÚ__init__Ú
ValueErrorÚ
isinstanceÚstrr   ÚlenÚofÚ	__enter__Úfor4   Ú	dir_cache)	ÚselfrJ   ÚmodeÚtarget_protocolÚtarget_optionsr4   ÚkwargsÚfilesÚ	__class__s	           €r   rC   zLibArchiveFileSystem.__init__^   s¦   ø€ ô0 	‰Ñ˜Ñ( Ò(Ø�3Š;ÜÐDÓEÐEÜ�bœ#ÔÜ˜rÑV¨OÐVÀÒ@TÐRTÑVˆEÜ�5‹z˜QŠÜ Ø˜R˜DÐ HÈÈÈqÐQóð ð �q‘ˆBØˆŒØ—,‘,“.ˆŒØ$ˆŒØˆ�r   c              #   ó¶   K  — | j                   j                  d«       t        | j                   | j                  ¬«      5 }|–— d d d «       y # 1 sw Y   y xY w­w)Nr   )r4   )rJ   r    r9   r4   )rL   Úarcs     r   Ú_open_archivez"LibArchiveFileSystem._open_archive…   sB   è ø€ à�‰�‰�QŒÜ˜4Ÿ7™7¨t¯©Ô?ð 	À3ØŠI÷	÷ 	ñ 	üs   ‚=A¿AÁ	AÁAÁAc                 ó@   •— t         ‰| �  |«      j                  d«      S )Nú/)rB   Ú_strip_protocolÚlstrip)ÚclsÚpathrR   s     €r   rX   z$LibArchiveFileSystem._strip_protocol‹   s    ø€ ô ‰wÑ& tÓ,×3Ñ3°CÓ8Ð8r   c                 óÂ  — ddddddddœ}| j                   �y i | _         g }| j                  «       5 }|D ]È  }|j                  s|j                  sŒ| j                   j	                  | j                  t        |j                  «      «      D �ci c]	  }||d	d
dœ“Œ c}«       |D �ci c]  }|t        |||   «      “Œ }}|j                  rd
nd|d<   |j                  |j                  «       || j                   |d   <   ŒÊ 	 d d d «       | j                   j	                  | j                  |«      D �ci c]	  }||d	d
dœ“Œ c}«       y c c}w c c}w # 1 sw Y   ŒQxY wc c}w )NÚpathnameÚsizeÚctimerM   ÚuidÚgidÚmtime)Únamer^   ÚcreatedrM   r`   ra   rb   r   Ú	directory)rc   r^   Útyper   rf   rc   )
rK   rU   ÚisdirÚisfileÚupdateÚ_all_dirnamesÚsetrc   ÚgetattrÚappend)rL   ÚfieldsÚ
list_namesrT   ÚentryÚdirnameÚkeyÚfs           r   Ú	_get_dirszLibArchiveFileSystem._get_dirs�   sr  € àØØØØØØñ
ˆð �>‰>Ð%ØàˆŒØˆ
Ø×ÑÓ!ð 	. SØò .�Ø—{’{¨5¯<ª<àØ—‘×%Ñ%ð (,×'9Ñ'9¼#¸e¿j¹j»/Ó'Jöà#ð  ¨'¸1ÀkÑ!RÑRòôð BHÖH¸#�Sœ' %¨°©Ó5Ñ5ÐH�ÐHØ+0¯;ª;™K¸F��&‘	Ø×!Ñ! %§*¡*Ô-à,-�—‘˜q ™yÒ)ñ.÷	.ð$ 	�‰×Ñð  $×1Ñ1°*Ó=öàð  '°1¸kÑJÑJòõ	
ùòùò
 I÷	.ð 	.üò&s1   ±AEÂEÂEÂ$EÂ;AEÄ0EÅ
EÅEc                 óT  — | j                  |«      }|dk7  rt        ‚t        «       }| j                  «       5 }|D ]K  }	|	j                  |k7  rŒ|	j
                  dk(  r n*|	j                  |	j
                  «      D ]  }
|
} ŒF t        ‚ d d d «       t        | ||¬«      S # 1 sw Y   ŒxY w)NÚrbr   )Úfsr[   Údata)	rX   ÚNotImplementedErrorÚbytesrU   r]   r^   Ú
get_blocksrD   r   )rL   r[   rM   r4   Ú
autocommitÚcache_optionsrP   rx   rT   rp   Úblocks              r   Ú_openzLibArchiveFileSystem._open¹   s¶   € ð ×#Ñ# DÓ)ˆØ�4Š<Ü%Ð%ä‹wˆØ×ÑÓ!ð 	% SØò %�Ø—>‘> TÒ)Øà—:‘: ’?áà"×-Ñ-¨e¯j©jÓ9ò %�EØ �DÙð%ô %Ð$ð%÷	%ô ˜T¨°4Ô8Ð8÷	%ð 	%ús   ·ABÂB')rv   NTN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úroot_markerr?   Úcachabler   rC   r   rU   ÚclassmethodrX   rt   r   Ú__classcell__)rR   s   @r   r;   r;   H   sq   ø„ ñð" €KØ€HØ€Hð ØØØØ%õ%ðN ñó ðð
 ó9ó ð9ò'
ðX ØØØ÷9r   r;   )Ú
contextlibr   Úctypesr   r   r   r   r   r	   r
   r*   Úlibarchive.ffir%   Úfsspecr   Úfsspec.archiver   Úfsspec.implementations.memoryr   Úfsspec.utilsr   r'   Úc_archive_pÚ	check_intr   Úhasattrr(   Ú	page_sizer9   r;   © r   r   ú<module>r”      s£   ðÝ %÷÷ ñ ó Ý å Ý 4Ý 4Ý +ñ ˜* e¨X°zÀ5ÓI€Ø ˜Ÿ™Ø˜sŸ™°Ð>ÀÀsÇ}Á}óÐ ñ �#�|Ó
$€ð Ø$)°uÈÏÉò #5ó ð#5ôLM9Ð4õ M9r   