diff options
| author | 2013-05-30 23:28:40 -0400 | |
|---|---|---|
| committer | 2013-05-31 12:00:22 +0200 | |
| commit | 42404434efe47d3d44e5e3c4c19c7c0034d2b844 (patch) | |
| tree | d90808f66fdc018cbbffc108dab4eb4a06f75975 /cython | |
| parent | 5970e52fa9682622d8fc97eb9c0ad82b4c3e792e (diff) | |
| download | libimobiledevice-42404434efe47d3d44e5e3c4c19c7c0034d2b844.tar.gz libimobiledevice-42404434efe47d3d44e5e3c4c19c7c0034d2b844.tar.bz2 | |
cython: Add read() method to AfcFile
Diffstat (limited to 'cython')
| -rw-r--r-- | cython/afc.pxi | 14 |
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 |
