From 509abefca5902e4f0decf40368a90265d1a598bd Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Wed, 10 Jun 2015 20:45:20 +0530 Subject: Add missing File APIs Volume.fopen() method mimics Python's built-in File object Example: with v.fopen("/path/to/file", "w") as f: f.write("hello world") fopen() returns a File object. Volume.open() method mimics os.open() Python API. Example: with File(v.open("/path/to/file", os.O_WRONLY | os.O_CREAT)) as f: f.write("hello world") open() returns the raw glfd that (as of today) needs to be passed to File class. In future, more APIs will be provided to directly use the glfd returned. Unlike their C versions, these methods do not return anything on success. If methods fail, exceptions are raised. Added docstrings to methods in File class. Change-Id: Ie46fc77a899806d396762e6740e1538ea298d6e2 Signed-off-by: Prashanth Pai Signed-off-by: Thiago da Silva --- gluster/api.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gluster/api.py') diff --git a/gluster/api.py b/gluster/api.py index 6bbd092..560ede8 100755 --- a/gluster/api.py +++ b/gluster/api.py @@ -396,6 +396,34 @@ glfs_setfsuid = ctypes.CFUNCTYPE(ctypes.c_int, glfs_setfsgid = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_uint)(('glfs_setfsgid', client)) +glfs_ftruncate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, + ctypes.c_int)(('glfs_ftruncate', client)) + +glfs_fgetxattr = ctypes.CFUNCTYPE(ctypes.c_ssize_t, + ctypes.c_void_p, + ctypes.c_char_p, + ctypes.c_void_p, + ctypes.c_size_t)(('glfs_fgetxattr', client)) + +glfs_fremovexattr = ctypes.CFUNCTYPE(ctypes.c_int, + ctypes.c_void_p, + ctypes.c_char_p)(('glfs_fremovexattr', + client)) + +glfs_fsetxattr = ctypes.CFUNCTYPE(ctypes.c_int, + ctypes.c_void_p, + ctypes.c_char_p, + ctypes.c_void_p, + ctypes.c_size_t, + ctypes.c_int)(('glfs_fsetxattr', client)) + +glfs_flistxattr = ctypes.CFUNCTYPE(ctypes.c_ssize_t, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_size_t)(('glfs_flistxattr', + client)) + + # TODO: creat and open fails on test_create_file_already_exists & test_open_file_not_exist functional testing, # noqa # when defined via function prototype.. Need to find RCA. For time being, using it from 'api.glfs_' # noqa -- cgit