File: //usr/lib/python3/dist-packages/django/core/files/__pycache__/locks.cpython-310.pyc
o
�a�
� @ s� d Z ddlZdZdd� Zejdkr�ddlZddlmZmZm Z m
Z
mZmZm
Z
mZmZ ddlmZmZmZ dZd Zd
Zee�ee
�krFeZneZe
ZG dd� de�ZG d
d� de �ZG dd� de�Zee�ZejjZee_eeeeeege_ ejj!Z!ee!_eeeeege!_ dd� Z"dd� Z#dS zddl$Z$e$jZe$jZe$jZW n e%e&fy� d Z ZZdd� Z"dd� Z#Y dS w dd� 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�unlockc C s t | 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�_fd s r
�nt) �POINTER� Structure�Union�byref�c_int64�c_ulong�c_void_p�sizeof�windll)�BOOL�DWORD�HANDLE� � c @ s e Zd ZdefdefgZdS )�_OFFSET�Offset�
OffsetHighN)�__name__�
__module__�__qualname__r �_fields_r r r r r 2 s �r c @ s"