Current File : //usr/lib64/python3.6/site-packages/borg/platform/__pycache__/base.cpython-36.pyc |
3
up�d�$ � @ s. d dl Z d dlZd dlZd dlZd dlmZ dZeedej�Z d&dd�Z
d'dd �Zyd d
lmZ d(dd�Z
W n ek
r� d)d
d�Z
Y nX dd� Zdd� Zdd� ZG dd� d�ZG dd� d�Zdd� Zd*dd�Zej� Zee�Zejd�d Zejjd�Ze�sdeej� f Zd d!� Zd"d#� Zd$d%� Z dS )+� N)�safe_unlinkz1.1_04� fdatasyncFc C s dS )zn
Saves ACL Entries
If `numeric_owner` is True the user/group field is not preserved only uid/gid
N� )�path�item�st�
numeric_ownerr r �/usr/lib64/python3.6/base.py�acl_get s r
c C s dS )z|
Restore ACL Entries
If `numeric_owner` is True the stored uid/gid is used instead
of the user/group names
Nr )r r r r r r �acl_set! s r )�lchflagsc C s t | |� d S )N)r )r � bsd_flags�fdr r r � set_flags- s r c C s d S )Nr )r r
r r r r r 0 s c C s t |dd�S )zHReturn BSD-style file flags for path or stat without following symlinks.Zst_flagsr )�getattr)r r r r r � get_flags4 s r c C sd t j| t j�}zDyt j|� W n0 tk
rN } z|jtjkr>� W Y d d }~X nX W d t j|� X d S )N)�os�open�O_RDONLY�fsync�OSError�errnoZEINVAL�close)r r Zos_errorr r r �sync_dir9 s r c C sF t td�rBttd| �}ytj| |||� W n tk
r@ Y nX d S )N�
posix_fadviseZPOSIX_FADV_)�hasattrr r r r )r �offset�lenZadvicer r r �safe_fadviseF s
r c @ sH e Zd ZdZddd�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 �binaryc C sJ |rdnd}|| _ |dkr*t||d�| _ntj||d�| _| jj� | _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.
Zxb�xN)�mode)r r �fr �fdopen�filenor )�selfr r r r"