�`^c@sfdZddlZejded�ddd��YZddd�Zd �Zd
ZdZdZ dS(
s:Extended file operations available in POSIX.
f = posixfile.open(filename, [mode, [bufsize]])
will create a new posixfile object
f = posixfile.fileopen(fileobject)
will create a posixfile object from a builtin file object
f.file()
will return the original builtin file object
f.dup()
will return a new file object based on a new filedescriptor
f.dup2(fd)
will return a new file object based on the given filedescriptor
f.flags(mode)
will turn on the associated flag (merge)
mode can contain the following characters:
(character representing a flag)
a append only flag
c close on exec flag
n no delay flag
s synchronization flag
(modifiers)
! turn flags 'off' instead of default 'on'
= copy flags 'as is' instead of default 'merge'
? return a string in which the characters represent the flags
that are set
note: - the '!' and '=' modifiers are mutually exclusive.
- the '?' modifier will return the status of the flags after they
have been changed by other characters in the mode string
f.lock(mode [, len [, start [, whence]]])
will (un)lock a region
mode can contain the following characters:
(character representing type of lock)
u unlock
r read lock
w write lock
(modifiers)
| wait until the lock can be granted
? return the first lock conflicting with the requested lock
or 'None' if there is no conflict. The lock returned is in the
format (mode, len, start, whence, pid) where mode is a
character representing the type of lock ('r' or 'w')
note: - the '?' modifier prevents a region from being locked; it is
query only
i�NsIThe posixfile module is deprecated; fcntl.lockf() provides better lockingit_posixfile_cBsheZdZddgZd�Zddd�Zd�Zd�Zd �Zd
�Z d�Z
d�ZRS(
s;File wrapper class that provides extra POSIX file routines.topentclosedcCs=|j}d|j|j|j|jtt|��dfS(Ns$<%s posixfile '%s', mode '%s' at %s>i(t_file_tstatesRtnametmodethextid(tselftfile((s/sys/lib/python2.7/posixfile.pyt__repr__Cs tri�cCs(ddl}|j|j|||��S(Ni�(t__builtin__tfileopenR(R RRtbufsizeR
((s/sys/lib/python2.7/posixfile.pyRLscCs�ddl}tt|��dkr0td�n||_xZt|�D]L}|jd�sFt||�}t||j �r�t
|||�q�qFqFW|S(Ni�s
<type 'file'>s,posixfile.fileopen() arg must be file objectt_(ttypestreprttypet TypeErrorRtdirt
startswithtgetattrt
isinstancetBuiltinMethodTypetsetattr(R R
Rtmaybemethodtattr((s/sys/lib/python2.7/posixfile.pyRPs cCs|jS(N(R(R ((s/sys/lib/python2.7/posixfile.pyR
`scCsOddl}t|d�s'td�n|j|j|jj��|jj�S(Ni�tfdopensdup() method unavailable(tposixthasattrtAttributeErrorRtdupRtfilenoR(R R((s/sys/lib/python2.7/posixfile.pyR!cscCsVddl}t|d�s'td�n|j|jj�|�|j||jj�S(Ni�Rsdup() method unavailable(RRR tdup2RR"RR(R tfdR((s/sys/lib/python2.7/posixfile.pyR#ks
cGsddl}ddl}|rIt|�dkr<td�n|d}nd}d}d|krq||jB}nd|kr�||jB}nd|kr�||jB}n|j}d |kr|j|j�|j d�}d
|kr�|@}q||B}n|j|j�|j
|�}d|krZd
|k}|j|j�|j|�}nd|krd}|j|j�|j d�}|j|@r�|d}n|j|j�|jd�d@r�|d}n|j|@r�d}n|j|@r|d}n|SdS(
Ni�isToo many argumentsit?tntatst=t!tct(
tfcntltostlenRtO_NDELAYtO_APPENDtO_SYNCRR"tF_GETFLtF_SETFLtF_SETFDtF_GETFD(R twhichR-R.tl_flagsR
tcur_fltarg((s/sys/lib/python2.7/posixfile.pytflagstsF
!
"
c
Gsddl}ddl}d|kr0|j}n9d|krH|j}n!d|kr`|j}n td�d|kr�|j}n!d|kr�|j}n |j}d}d}d} t |�d kr�|d} nct |�d
kr�\} }nBt |�dkr|\} }}nt |�dkr6td�nddl
}
ddl}|
jdkr�|j
d|| |j�||�}nW|
jd kr�|j
d|||| ddd�}n!|j
d|||| dd�}|j|jj�||�}d|kr|
jd!kr8|jd|�\}} }
}}n�|
jd"krq|jd|�\}}}} }}
}nZ|
jdkr�|jd|�\}}}} }
}n$|jd|�\}}}} }}
||jkr||jkr�| |||
fSd| |||
fSqndS(#Ni�twRtusno type of lock specifiedt|R%iiiistoo many argumentstnetbsd1topenbsd2tfreebsd2tfreebsd3tfreebsd4tfreebsd5tfreebsd6tfreebsd7tfreebsd8tbsdos2tbsdos3tbsdos4t
lxxxxlxxxxlhhtaix3taix4thhllliithhllhhtlinux2(R?R@RARBRCRDRERFRGRHRIRJ(RLRM( R?R@RARBRCRDRHRIRJ(RLRM(tstructR-tF_WRLCKtF_RDLCKtF_UNLCKRtF_SETLKWtF_GETLKtF_SETLKR/tsysR.tplatformtpacktgetpidRR"tunpack(R thowtargsRQR-tl_typetcmdtl_whencetl_starttl_lenRXR.tflocktl_pidtl_sysidtl_vfs((s/sys/lib/python2.7/posixfile.pytlock�sj
$*'$(t__name__t
__module__t__doc__RRRRR
R!R#R;Rh(((s/sys/lib/python2.7/posixfile.pyR;s %RcCst�j|||�S(s4Public routine to open a file as a posixfile object.(RR(RRR((s/sys/lib/python2.7/posixfile.pyR�scCst�j|�S(sCPublic routine to get a posixfile object from a Python file object.(RR(R
((s/sys/lib/python2.7/posixfile.pyR�sii((
RktwarningstwarntDeprecationWarningRRRtSEEK_SETtSEEK_CURtSEEK_END(((s/sys/lib/python2.7/posixfile.pyt<module>6s
�
|