|
@@ -37,14 +37,13 @@ cdef extern from "sys/acl.h":
|
|
|
|
|
|
def listxattr(path, *, follow_symlinks=True):
|
|
|
def func(path, buf, size):
|
|
|
- cdef char *buffer = <char *> buf
|
|
|
if isinstance(path, int):
|
|
|
- return c_flistxattr(path, buffer, size, XATTR_NOFLAGS)
|
|
|
+ return c_flistxattr(path, <char *> buf, size, XATTR_NOFLAGS)
|
|
|
else:
|
|
|
if follow_symlinks:
|
|
|
- return c_listxattr(path, buffer, size, XATTR_NOFLAGS)
|
|
|
+ return c_listxattr(path, <char *> buf, size, XATTR_NOFLAGS)
|
|
|
else:
|
|
|
- return c_listxattr(path, buffer, size, XATTR_NOFOLLOW)
|
|
|
+ return c_listxattr(path, <char *> buf, size, XATTR_NOFOLLOW)
|
|
|
|
|
|
n, buf = _listxattr_inner(func, path)
|
|
|
return [os.fsdecode(name) for name in split_string0(buf[:n]) if name]
|
|
@@ -52,29 +51,27 @@ def listxattr(path, *, follow_symlinks=True):
|
|
|
|
|
|
def getxattr(path, name, *, follow_symlinks=True):
|
|
|
def func(path, name, buf, size):
|
|
|
- cdef char *buffer = <char *> buf
|
|
|
if isinstance(path, int):
|
|
|
- return c_fgetxattr(path, name, buffer, size, 0, XATTR_NOFLAGS)
|
|
|
+ return c_fgetxattr(path, name, <char *> buf, size, 0, XATTR_NOFLAGS)
|
|
|
else:
|
|
|
if follow_symlinks:
|
|
|
- return c_getxattr(path, name, buffer, size, 0, XATTR_NOFLAGS)
|
|
|
+ return c_getxattr(path, name, <char *> buf, size, 0, XATTR_NOFLAGS)
|
|
|
else:
|
|
|
- return c_getxattr(path, name, buffer, size, 0, XATTR_NOFOLLOW)
|
|
|
+ return c_getxattr(path, name, <char *> buf, size, 0, XATTR_NOFOLLOW)
|
|
|
|
|
|
n, buf = _getxattr_inner(func, path, name)
|
|
|
- return buf[:n] or None
|
|
|
+ return bytes(buf[:n])
|
|
|
|
|
|
|
|
|
def setxattr(path, name, value, *, follow_symlinks=True):
|
|
|
def func(path, name, value, size):
|
|
|
- cdef char *val = NULL if value is None else <char *> value
|
|
|
if isinstance(path, int):
|
|
|
- return c_fsetxattr(path, name, val, size, 0, XATTR_NOFLAGS)
|
|
|
+ return c_fsetxattr(path, name, <char *> value, size, 0, XATTR_NOFLAGS)
|
|
|
else:
|
|
|
if follow_symlinks:
|
|
|
- return c_setxattr(path, name, val, size, 0, XATTR_NOFLAGS)
|
|
|
+ return c_setxattr(path, name, <char *> value, size, 0, XATTR_NOFLAGS)
|
|
|
else:
|
|
|
- return c_setxattr(path, name, val, size, 0, XATTR_NOFOLLOW)
|
|
|
+ return c_setxattr(path, name, <char *> value, size, 0, XATTR_NOFOLLOW)
|
|
|
|
|
|
_setxattr_inner(func, path, name, value)
|
|
|
|