diff options
| author | 2018-07-30 10:43:57 -0700 | |
|---|---|---|
| committer | 2021-01-03 23:26:52 +0100 | |
| commit | 7044571b4f243d2fda4dd3aa491f2f279787ee19 (patch) | |
| tree | 845ec0e4a24ff9bae445521cdcfff016b30c4fb3 | |
| parent | 52371bccdcb1b0fe98930e79ac2ab9bdad2700e2 (diff) | |
| download | libimobiledevice-7044571b4f243d2fda4dd3aa491f2f279787ee19.tar.gz libimobiledevice-7044571b4f243d2fda4dd3aa491f2f279787ee19.tar.bz2 | |
Fixed AFC afc.pxi definitions for Python2/3 compatibility. Added missing public method 'remove_path_and_contents'
| -rw-r--r-- | cython/afc.pxi | 28 | 
1 files changed, 16 insertions, 12 deletions
| diff --git a/cython/afc.pxi b/cython/afc.pxi index e34588f..6bd8182 100644 --- a/cython/afc.pxi +++ b/cython/afc.pxi @@ -52,6 +52,7 @@ cdef extern from "libimobiledevice/afc.h":      afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list)      afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist)      afc_error_t afc_remove_path(afc_client_t client, char *path) +    afc_error_t afc_remove_path_and_contents(afc_client_t client, char *path)      afc_error_t afc_rename_path(afc_client_t client, char *f, char *to)      afc_error_t afc_make_directory(afc_client_t client, char *dir)      afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize) @@ -235,17 +236,17 @@ cdef class AfcClient(BaseService):              afc_file_mode_t c_mode              uint64_t handle              AfcFile f -        if mode == <bytes>'r': +        if mode == b'r':              c_mode = AFC_FOPEN_RDONLY -        elif mode == <bytes>'r+': +        elif mode == b'r+':              c_mode = AFC_FOPEN_RW -        elif mode == <bytes>'w': +        elif mode == b'w':              c_mode = AFC_FOPEN_WRONLY -        elif mode == <bytes>'w+': +        elif mode == b'w+':              c_mode = AFC_FOPEN_WR -        elif mode == <bytes>'a': +        elif mode == b'a':              c_mode = AFC_FOPEN_APPEND -        elif mode == <bytes>'a+': +        elif mode == b'a+':              c_mode = AFC_FOPEN_RDAPPEND          else:              raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") @@ -282,6 +283,9 @@ cdef class AfcClient(BaseService):      cpdef remove_path(self, bytes path):          self.handle_error(afc_remove_path(self._c_client, path)) +    cpdef remove_path_and_contents(self, bytes path): +        self.handle_error(afc_remove_path_and_contents(self._c_client, path)) +      cpdef rename_path(self, bytes f, bytes t):          self.handle_error(afc_rename_path(self._c_client, f, t)) @@ -308,17 +312,17 @@ cdef class Afc2Client(AfcClient):              afc_file_mode_t c_mode              uint64_t handle              AfcFile f -        if mode == <bytes>'r': +        if mode == b'r':              c_mode = AFC_FOPEN_RDONLY -        elif mode == <bytes>'r+': +        elif mode == b'r+':              c_mode = AFC_FOPEN_RW -        elif mode == <bytes>'w': +        elif mode == b'w':              c_mode = AFC_FOPEN_WRONLY -        elif mode == <bytes>'w+': +        elif mode == b'w+':              c_mode = AFC_FOPEN_WR -        elif mode == <bytes>'a': +        elif mode == b'a':              c_mode = AFC_FOPEN_APPEND -        elif mode == <bytes>'a+': +        elif mode == b'a+':              c_mode = AFC_FOPEN_RDAPPEND          else:              raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") | 
