From 7412042b144b75718d84d14f2d0a1c0b11afc61d Mon Sep 17 00:00:00 2001 From: Dawn K. Isabel Date: Thu, 30 May 2013 23:30:34 -0400 Subject: cython: Add Afc2Client class to allow jailbroken filesystem access --- cython/afc.pxi | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'cython') 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 == 'r': + c_mode = AFC_FOPEN_RDONLY + elif mode == 'r+': + c_mode = AFC_FOPEN_RW + elif mode == 'w': + c_mode = AFC_FOPEN_WRONLY + elif mode == 'w+': + c_mode = AFC_FOPEN_WR + elif mode == 'a': + c_mode = AFC_FOPEN_APPEND + elif mode == '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 = self + f._filename = filename + + return f + -- cgit v1.1-32-gdbae