HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib64/python3.9/site-packages/borg/platform/__pycache__/base.cpython-39.opt-1.pyc
a

HZ�h}*�@srddlZddlZddlZddlZddlmZddlmZdZe	edej
�Zddlm
Z
dd	�d
d�Zdd	�dd
�Zdd	�dd�Zd0dd�Zd1dd�ZzddlmZd2dd�ZWney�d3dd�ZYn0d4dd�Zdd�Zdd�ZGdd�d�ZGd d!�d!�Zd"d#�Zd5d%d&�Ze��Zee�Ze� d'�dZej!�"d(�Z#e#�sVe�d)e�$���Z#d*d+�Z%d,d-�Z&d.d/�Z'dS)6�N)�safe_unlink)�is_win32z1.2_05�	fdatasync�)�ENOATTRF)�follow_symlinkscCsgS)a
    Return xattr names of a file (list of bytes objects).

    *path* can either be a path (bytes) or an open file descriptor (int).
    *follow_symlinks* indicates whether symlinks should be followed
    and only applies when *path* is not an open file descriptor.
    �)�pathrrr�8/usr/lib64/python3.9/site-packages/borg/platform/base.py�	listxattrsrcCsttt�t�|��dS)a:
    Read xattr and return its value (as bytes).

    *path* can either be a path (bytes) or an open file descriptor (int).
    *name* is the name of the xattr to read (bytes).
    *follow_symlinks* indicates whether symlinks should be followed
    and only applies when *path* is not an open file descriptor.
    N)�OSErrorr�os�strerror)r	�namerrrr
�getxattr'srcCsdS)aP
    Write xattr on *path*.

    *path* can either be a path (bytes) or an open file descriptor (int).
    *name* is the name of the xattr to read (bytes).
    *value* is the value to write (bytes).
    *follow_symlinks* indicates whether symlinks should be followed
    and only applies when *path* is not an open file descriptor.
    Nr)r	r�valuerrrr
�setxattr5srcCsdS)zl
    Saves ACL Entries

    If `numeric_ids` is True the user/group field is not preserved only uid/gid
    Nr)r	�item�st�numeric_ids�fdrrr
�acl_getAsrcCsdS)zz
    Restore ACL Entries

    If `numeric_ids` is True the stored uid/gid is used instead
    of the user/group names
    Nr)r	rrrrrr
�acl_setIsr��lchflagscCst||�dS�Nr�r	Z	bsd_flagsrrrr
�	set_flagsUsrcCsdSrrrrrr
rXscCst|dd�S)zHReturn BSD-style file flags for path or stat without following symlinks.�st_flagsr)�getattr)r	rrrrr
�	get_flags\sr c
CsxtrdSt�|tj�}zPzt�|�Wn2tyX}z|jtjkrD�WYd}~n
d}~00Wt�|�nt�|�0dSr)	rr
�open�O_RDONLY�fsyncr�errno�EINVAL�close)r	rZos_errorrrr
�sync_dirasr'cCsDttd�r@ttd|�}zt�||||�Wnty>Yn0dS)N�
posix_fadviseZPOSIX_FADV_)�hasattrr
rr(r)r�offset�lenZadvicerrr
�safe_fadvisers
r,c@sHeZdZdZddd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�SyncFilea(
    A file class that is supposed to enable write ordering (one way or another) and data durability after close().

    The degree to which either is possible varies with operating system, file system and hardware.

    This fallback implements a naive and slow way of doing this. On some operating systems it can't actually
    guarantee any of the above, since fsync() doesn't guarantee it. Furthermore it may not be possible at all
    to satisfy the above guarantees on some hardware or operating systems. In these cases we hope that the thorough
    checksumming implemented catches any corrupted data due to misordered, delayed or partial writes.

    Note that POSIX doesn't specify *anything* about power failures (or similar failures). A system that
    routinely loses files or corrupts file on power loss is POSIX compliant.

    Calling SyncFile(path) for an existing path will raise FileExistsError, see comment in __init__.

    TODO: Use F_FULLSYNC on OSX.
    TODO: A Windows implementation should use CreateFile with FILE_FLAG_WRITE_THROUGH.
    NF�r�binarycCsJ|rdnd}||_|dur*t||d�|_ntj||d�|_|j��|_dS)aJ
        Open a SyncFile.

        :param path: full path/filename
        :param fd: additionally to path, it is possible to give an already open OS-level fd
               that corresponds to path (like from os.open(path, ...) or os.mkstemp(...))
        :param binary: whether to open in binary mode, default is False.
        �xb�xN)�mode)r	r!�fr
�fdopen�filenor)�selfr	rr/r2rrr
�__init__�s	zSyncFile.__init__cCs|Srr)r6rrr
�	__enter__�szSyncFile.__enter__cCs|��dSr)r&)r6�exc_type�exc_val�exc_tbrrr
�__exit__�szSyncFile.__exit__cCs|j�|�dSr)r3�write)r6�datarrr
r=�szSyncFile.writecCs6ddlm}|j��|�|j�t|jddd�dS)z�
        Synchronize file contents. Everything written prior to sync() must become durable before anything written
        after sync().
        ���platformrZDONTNEEDN)�rAr3�flushrrr,)r6rArrr
�sync�s
z
SyncFile.syncc	Csbddlm}d}z2tj�|j�}|��W|j��|r^|�|�n|j��|r\|�|�0dS)zsync() and close.r?r@N)	rBrAr
r	�dirnamerDr3r&r')r6rArErrr
r&�s

�
zSyncFile.close)
�__name__�
__module__�__qualname__�__doc__r7r8r<r=rDr&rrrr
r-�sr-c@s*eZdZdZd
dd�Zdd�Zdd�Zd	S)�SaveFilea�
    Update file contents atomically.

    Must be used as a context manager (defining the scope of the transaction).

    On a journaling file system the file contents are always updated
    atomically and won't become corrupted, even on power failures or
    crashes (for caveats see SyncFile).

    SaveFile can safely by used in parallel (e.g. by multiple processes) to write
    to the same target path. Whatever writer finishes last (executes the os.replace
    last) "wins" and has successfully written its content to the target path.
    Internally used temporary files are created in the target directory and are
    named <BASENAME>-<RANDOMCHARS>.tmp and cleaned up in normal and error conditions.
    FcCsB||_||_tj�|�|_tj�|�d|_d|_d|_d|_	dS)N�-)
r/r	r
rE�dir�basename�
tmp_prefix�tmp_fd�	tmp_fnamer3)r6r	r/rrr
r7�szSaveFile.__init__cCsRddlm}ddlm}||jd|jdd�\|_|_|j|j|j|j	d�|_
|j
S)Nr?r@)�mkstemp_modez.tmpi�)�prefix�suffixrLr2r.)rBrAZ
helpers.fsrQrNrLrOrPr-r/r3)r6rArQrrr
r8�s
zSaveFile.__enter__c	Cs�ddlm}|j��d|_|dur2t|j�dSzDzt�|j|j	�Wnt
yft|j��Yn0W|�|j�n|�|j�0dS)Nr?r@)
rBrAr3r&rOrrPr
�replacer	rr'rL)r6r9r:r;rArrr
r<�s



zSaveFile.__exit__N)F)rFrGrHrIr7r8r<rrrr
rJ�s
	rJcCst|�S)z}terminal output width of string <s>

    For western scripts, this is just len(s), but for cjk glyphs, 2 cells are used.
    )r+)�srrr
�swidth�srVrBcCsn|��}|r|dkrt��}zt�|ddtjdtj�}WntyJYn 0|D]}|drP|d}qjqP|S)zpGet fully qualified domain name from name.

    An empty argument is interpreted as meaning the local host.
    z0.0.0.0Nr�)�strip�socket�gethostnameZgetaddrinfoZ
SOCK_DGRAMZAI_CANONNAMEr)r�addrs�addrrrr
�getfqdnsr]�.ZBORG_HOST_ID�@cCsd}t��}t||fS)z�
    Return identification tuple (hostname, pid, thread_id) for 'us'.
    This always returns the current pid, which might be different from before, e.g. if daemonize() was used.

    Note: Currently thread_id is *always* zero.
    r)r
�getpid�hostid)Z	thread_id�pidrrr
�get_process_id(srccCst�dS)ze
    Check if the (host, pid, thread_id) combination corresponds to a potentially alive process.
    N��NotImplementedError)�hostrb�threadrrr
�
process_alive4srhcCst�dS)zReturn whether *pid* is alive.Nrd)rbrrr
�local_pid_alive;sri)FN)FN)N)N)N)rB)(r$r
rYZuuidZborg.helpersrZborg.platformflagsrZAPI_VERSIONrr#rZxattrrrrrrrrr�ImportErrorr r'r,r-rJrVr]rZ�hostnameZfqdn�split�environ�getraZgetnodercrhrirrrr
�<module>sD

	
G2