HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/django/core/files/__pycache__/locks.cpython-310.pyc
o

�a�
�	@s�dZddlZdZdd�Zejdkr�ddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZmZmZdZd	Zd
Zee�ee
�krFeZneZe
ZGdd�de�ZGd
d�de	�ZGdd�de�Zee�ZejjZee_eeeeeege_ ejj!Z!ee!_eeeeege!_ dd�Z"dd�Z#dSzddl$Z$e$jZe$jZe$jZWne%e&fy�dZZZdd�Z"dd�Z#YdSwdd�Z"dd�Z#dS)aw
Portable file locking utilities.

Based partially on an example by Jonathan Feignberg in the Python
Cookbook [1] (licensed under the Python Software License) and a ctypes port by
Anatoly Techtonik for Roundup [2] (license [3]).

[1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203
[2] https://sourceforge.net/p/roundup/code/ci/default/tree/roundup/backends/portalocker.py
[3] https://sourceforge.net/p/roundup/code/ci/default/tree/COPYING.txt

Example Usage::

    >>> from django.core.files import locks
    >>> with open('./file', 'wb') as f:
    ...     locks.lock(f, locks.LOCK_EX)
    ...     f.write('Django')
�N)�LOCK_EX�LOCK_SH�LOCK_NB�lock�unlockcCst|d�r	|��S|S)zCGet a filedescriptor from something which could be a file or an fd.�fileno)�hasattrr��f�r�9/usr/lib/python3/dist-packages/django/core/files/locks.py�_fdsr
�nt)	�POINTER�	Structure�Union�byref�c_int64�c_ulong�c_void_p�sizeof�windll)�BOOL�DWORD�HANDLE��c@seZdZdefdefgZdS)�_OFFSET�Offset�
OffsetHighN)�__name__�
__module__�__qualname__r�_fields_rrrrr2s�rc@s"eZdZdgZdefdefgZdS)�
_OFFSET_UNION�_offset�PointerN)r r!r"�_anonymous_r�PVOIDr#rrrrr$7s
�r$c@s.eZdZdgZdefdefdefdefgZdS)�
OVERLAPPED�
_offset_union�Internal�InternalHigh�hEventN)r r!r"r'�	ULONG_PTRr$rr#rrrrr)=s�r)cCs2t�t|��}t�}t||dddt|��}t|�S�Nrl�)�msvcrt�
get_osfhandler
r)�
LockFileExr�bool)r
�flags�hfile�
overlapped�retrrrrOsrcCs0t�t|��}t�}t|dddt|��}t|�Sr/)r0r1r
r)�UnlockFileExrr3)r
r5r6r7rrrrUsrcC�dS)NFr�r
r4rrrre�cCr9�NTrr	rrrrir;cCs,zt�t|�|�WdStyYdSw)NTF)�fcntl�flockr
�BlockingIOErrorr:rrrrms�cCst�t|�tj�dSr<)r=r>r
�LOCK_UNr	rrrrts)'�__doc__�os�__all__r
�namer0�ctypesrrrrrrrrr�ctypes.wintypesrrrrrrr.r(rr$r)�LPOVERLAPPED�kernel32r2�restype�argtypesr8rrr=�ImportError�AttributeErrorrrrr�<module>sN
,
�