blob: 830bb894f2e8dd4f1c54d77e50c3794f1a4a9da0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import six
cdef extern from "sys/clonefile.h" nogil:
int clonefile(const char * src, const char * dst, int flags)
cdef extern from "Python.h":
ctypedef struct PyObject
cdef PyObject *PyExc_OSError
PyObject *PyErr_SetFromErrno(PyObject *)
cdef int _macos_clone_file(const char* src, const char* dst) except? 0:
if clonefile(src, dst, 0) == -1:
PyErr_SetFromErrno(PyExc_OSError)
return 0
return 1
def macos_clone_file(src, dst):
return _macos_clone_file(six.ensure_binary(src), six.ensure_binary(dst)) != 0
|