summaryrefslogtreecommitdiffstats
path: root/cython
diff options
context:
space:
mode:
Diffstat (limited to 'cython')
-rw-r--r--cython/afc.pxi14
1 files changed, 14 insertions, 0 deletions
diff --git a/cython/afc.pxi b/cython/afc.pxi
index 2608ee6..1ca4378 100644
--- a/cython/afc.pxi
+++ b/cython/afc.pxi
@@ -133,6 +133,20 @@ cdef class AfcFile(Base):
cpdef truncate(self, uint64_t newsize):
self.handle_error(afc_file_truncate(self._client._c_client, self._c_handle, newsize))
+ cpdef bytes read(self, uint32_t size):
+ cdef:
+ uint32_t bytes_read
+ char* c_data = <char *>malloc(size)
+ bytes result
+ try:
+ self.handle_error(afc_file_read(self._client._c_client, self._c_handle, c_data, size, &bytes_read))
+ result = c_data[:bytes_read]
+ return result
+ except BaseError, e:
+ raise
+ finally:
+ free(c_data)
+
cpdef uint32_t write(self, bytes data):
cdef:
uint32_t bytes_written