diff options
| author | 2013-05-30 23:30:34 -0400 | |
|---|---|---|
| committer | 2013-05-31 12:00:22 +0200 | |
| commit | 7412042b144b75718d84d14f2d0a1c0b11afc61d (patch) | |
| tree | 404814eb934de626521561d7b9e2a7c4356dc02b /cython/afc.pxi | |
| parent | 891cc8046e1cb2adc8f0bdffaed1733be7b8076c (diff) | |
| download | libimobiledevice-7412042b144b75718d84d14f2d0a1c0b11afc61d.tar.gz libimobiledevice-7412042b144b75718d84d14f2d0a1c0b11afc61d.tar.bz2 | |
cython: Add Afc2Client class to allow jailbroken filesystem access
Diffstat (limited to 'cython/afc.pxi')
| -rw-r--r-- | cython/afc.pxi | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cython/afc.pxi b/cython/afc.pxi index 3e6f6dd..6df9b45 100644 --- a/cython/afc.pxi +++ b/cython/afc.pxi | |||
| @@ -294,3 +294,35 @@ cdef class AfcClient(BaseService): | |||
| 294 | 294 | ||
| 295 | cpdef set_file_time(self, bytes path, uint64_t mtime): | 295 | cpdef set_file_time(self, bytes path, uint64_t mtime): |
| 296 | self.handle_error(afc_set_file_time(self._c_client, path, mtime)) | 296 | self.handle_error(afc_set_file_time(self._c_client, path, mtime)) |
| 297 | |||
| 298 | cdef class Afc2Client(AfcClient): | ||
| 299 | __service_name__ = "com.apple.afc2" | ||
| 300 | |||
| 301 | cpdef AfcFile open(self, bytes filename, bytes mode=b'r'): | ||
| 302 | cdef: | ||
| 303 | afc_file_mode_t c_mode | ||
| 304 | uint64_t handle | ||
| 305 | AfcFile f | ||
| 306 | if mode == <bytes>'r': | ||
| 307 | c_mode = AFC_FOPEN_RDONLY | ||
| 308 | elif mode == <bytes>'r+': | ||
| 309 | c_mode = AFC_FOPEN_RW | ||
| 310 | elif mode == <bytes>'w': | ||
| 311 | c_mode = AFC_FOPEN_WRONLY | ||
| 312 | elif mode == <bytes>'w+': | ||
| 313 | c_mode = AFC_FOPEN_WR | ||
| 314 | elif mode == <bytes>'a': | ||
| 315 | c_mode = AFC_FOPEN_APPEND | ||
| 316 | elif mode == <bytes>'a+': | ||
| 317 | c_mode = AFC_FOPEN_RDAPPEND | ||
| 318 | else: | ||
| 319 | raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") | ||
| 320 | |||
| 321 | self.handle_error(afc_file_open(self._c_client, filename, c_mode, &handle)) | ||
| 322 | f = AfcFile.__new__(AfcFile) | ||
| 323 | f._c_handle = handle | ||
| 324 | f._client = <AfcClient>self | ||
| 325 | f._filename = filename | ||
| 326 | |||
| 327 | return f | ||
| 328 | |||
