summaryrefslogtreecommitdiffstats
path: root/cython/afc.pxi
diff options
context:
space:
mode:
Diffstat (limited to 'cython/afc.pxi')
-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):
133 cpdef truncate(self, uint64_t newsize): 133 cpdef truncate(self, uint64_t newsize):
134 self.handle_error(afc_file_truncate(self._client._c_client, self._c_handle, newsize)) 134 self.handle_error(afc_file_truncate(self._client._c_client, self._c_handle, newsize))
135 135
136 cpdef bytes read(self, uint32_t size):
137 cdef:
138 uint32_t bytes_read
139 char* c_data = <char *>malloc(size)
140 bytes result
141 try:
142 self.handle_error(afc_file_read(self._client._c_client, self._c_handle, c_data, size, &bytes_read))
143 result = c_data[:bytes_read]
144 return result
145 except BaseError, e:
146 raise
147 finally:
148 free(c_data)
149
136 cpdef uint32_t write(self, bytes data): 150 cpdef uint32_t write(self, bytes data):
137 cdef: 151 cdef:
138 uint32_t bytes_written 152 uint32_t bytes_written