summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dawn K. Isabel2013-05-30 23:30:34 -0400
committerGravatar Martin Szulecki2013-05-31 12:00:22 +0200
commit7412042b144b75718d84d14f2d0a1c0b11afc61d (patch)
tree404814eb934de626521561d7b9e2a7c4356dc02b
parent891cc8046e1cb2adc8f0bdffaed1733be7b8076c (diff)
downloadlibimobiledevice-7412042b144b75718d84d14f2d0a1c0b11afc61d.tar.gz
libimobiledevice-7412042b144b75718d84d14f2d0a1c0b11afc61d.tar.bz2
cython: Add Afc2Client class to allow jailbroken filesystem access
-rw-r--r--cython/afc.pxi32
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):
cpdef set_file_time(self, bytes path, uint64_t mtime):
self.handle_error(afc_set_file_time(self._c_client, path, mtime))
+
+cdef class Afc2Client(AfcClient):
+ __service_name__ = "com.apple.afc2"
+
+ cpdef AfcFile open(self, bytes filename, bytes mode=b'r'):
+ cdef:
+ afc_file_mode_t c_mode
+ uint64_t handle
+ AfcFile f
+ if mode == <bytes>'r':
+ c_mode = AFC_FOPEN_RDONLY
+ elif mode == <bytes>'r+':
+ c_mode = AFC_FOPEN_RW
+ elif mode == <bytes>'w':
+ c_mode = AFC_FOPEN_WRONLY
+ elif mode == <bytes>'w+':
+ c_mode = AFC_FOPEN_WR
+ elif mode == <bytes>'a':
+ c_mode = AFC_FOPEN_APPEND
+ elif mode == <bytes>'a+':
+ c_mode = AFC_FOPEN_RDAPPEND
+ else:
+ raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'")
+
+ self.handle_error(afc_file_open(self._c_client, filename, c_mode, &handle))
+ f = AfcFile.__new__(AfcFile)
+ f._c_handle = handle
+ f._client = <AfcClient>self
+ f._filename = filename
+
+ return f
+