File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -59,8 +59,16 @@ def _cdll(name):
59
59
"'clonefile' not supported by the standard library" ,
60
60
)
61
61
62
+ def errcheck (ret , _func , _args ):
63
+ if ret :
64
+ err = ctypes .get_errno ()
65
+ msg = os .strerror (err )
66
+ raise OSError (err , msg )
67
+ return ret
68
+
62
69
clonefile .argtypes = [ctypes .c_char_p , ctypes .c_char_p , ctypes .c_int ]
63
70
clonefile .restype = ctypes .c_int
71
+ clonefile .errcheck = errcheck
64
72
65
73
return clonefile
66
74
@@ -71,15 +79,11 @@ def _cdll(name):
71
79
clonefile = _clonefile ()
72
80
73
81
def reflink (src , dst ):
74
- ret = clonefile (
82
+ clonefile (
75
83
ctypes .c_char_p (os .fsencode (src )),
76
84
ctypes .c_char_p (os .fsencode (dst )),
77
85
ctypes .c_int (0 ),
78
86
)
79
- if ret :
80
- err = ctypes .get_errno ()
81
- msg = os .strerror (err )
82
- raise OSError (err , msg )
83
87
84
88
elif sys .platform == "linux" :
85
89
import fcntl # pylint: disable=import-error
You can’t perform that action at this time.
0 commit comments