summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dawn K. Isabel2013-05-30 23:28:40 -0400
committerGravatar Martin Szulecki2013-05-31 12:00:22 +0200
commit42404434efe47d3d44e5e3c4c19c7c0034d2b844 (patch)
treed90808f66fdc018cbbffc108dab4eb4a06f75975
parent5970e52fa9682622d8fc97eb9c0ad82b4c3e792e (diff)
downloadlibimobiledevice-42404434efe47d3d44e5e3c4c19c7c0034d2b844.tar.gz
libimobiledevice-42404434efe47d3d44e5e3c4c19c7c0034d2b844.tar.bz2
cython: Add read() method to AfcFile
-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