diff options
| -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": | |||
| 52 | afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list) | 52 | afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list) |
| 53 | afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist) | 53 | afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist) |
| 54 | afc_error_t afc_remove_path(afc_client_t client, char *path) | 54 | afc_error_t afc_remove_path(afc_client_t client, char *path) |
| 55 | afc_error_t afc_remove_path_and_contents(afc_client_t client, char *path) | ||
| 55 | afc_error_t afc_rename_path(afc_client_t client, char *f, char *to) | 56 | afc_error_t afc_rename_path(afc_client_t client, char *f, char *to) |
| 56 | afc_error_t afc_make_directory(afc_client_t client, char *dir) | 57 | afc_error_t afc_make_directory(afc_client_t client, char *dir) |
| 57 | afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize) | 58 | afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize) |
| @@ -235,17 +236,17 @@ cdef class AfcClient(BaseService): | |||
| 235 | afc_file_mode_t c_mode | 236 | afc_file_mode_t c_mode |
| 236 | uint64_t handle | 237 | uint64_t handle |
| 237 | AfcFile f | 238 | AfcFile f |
| 238 | if mode == <bytes>'r': | 239 | if mode == b'r': |
| 239 | c_mode = AFC_FOPEN_RDONLY | 240 | c_mode = AFC_FOPEN_RDONLY |
| 240 | elif mode == <bytes>'r+': | 241 | elif mode == b'r+': |
| 241 | c_mode = AFC_FOPEN_RW | 242 | c_mode = AFC_FOPEN_RW |
| 242 | elif mode == <bytes>'w': | 243 | elif mode == b'w': |
| 243 | c_mode = AFC_FOPEN_WRONLY | 244 | c_mode = AFC_FOPEN_WRONLY |
| 244 | elif mode == <bytes>'w+': | 245 | elif mode == b'w+': |
| 245 | c_mode = AFC_FOPEN_WR | 246 | c_mode = AFC_FOPEN_WR |
| 246 | elif mode == <bytes>'a': | 247 | elif mode == b'a': |
| 247 | c_mode = AFC_FOPEN_APPEND | 248 | c_mode = AFC_FOPEN_APPEND |
| 248 | elif mode == <bytes>'a+': | 249 | elif mode == b'a+': |
| 249 | c_mode = AFC_FOPEN_RDAPPEND | 250 | c_mode = AFC_FOPEN_RDAPPEND |
| 250 | else: | 251 | else: |
| 251 | raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") | 252 | raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") |
| @@ -282,6 +283,9 @@ cdef class AfcClient(BaseService): | |||
| 282 | cpdef remove_path(self, bytes path): | 283 | cpdef remove_path(self, bytes path): |
| 283 | self.handle_error(afc_remove_path(self._c_client, path)) | 284 | self.handle_error(afc_remove_path(self._c_client, path)) |
| 284 | 285 | ||
| 286 | cpdef remove_path_and_contents(self, bytes path): | ||
| 287 | self.handle_error(afc_remove_path_and_contents(self._c_client, path)) | ||
| 288 | |||
| 285 | cpdef rename_path(self, bytes f, bytes t): | 289 | cpdef rename_path(self, bytes f, bytes t): |
| 286 | self.handle_error(afc_rename_path(self._c_client, f, t)) | 290 | self.handle_error(afc_rename_path(self._c_client, f, t)) |
| 287 | 291 | ||
| @@ -308,17 +312,17 @@ cdef class Afc2Client(AfcClient): | |||
| 308 | afc_file_mode_t c_mode | 312 | afc_file_mode_t c_mode |
| 309 | uint64_t handle | 313 | uint64_t handle |
| 310 | AfcFile f | 314 | AfcFile f |
| 311 | if mode == <bytes>'r': | 315 | if mode == b'r': |
| 312 | c_mode = AFC_FOPEN_RDONLY | 316 | c_mode = AFC_FOPEN_RDONLY |
| 313 | elif mode == <bytes>'r+': | 317 | elif mode == b'r+': |
| 314 | c_mode = AFC_FOPEN_RW | 318 | c_mode = AFC_FOPEN_RW |
| 315 | elif mode == <bytes>'w': | 319 | elif mode == b'w': |
| 316 | c_mode = AFC_FOPEN_WRONLY | 320 | c_mode = AFC_FOPEN_WRONLY |
| 317 | elif mode == <bytes>'w+': | 321 | elif mode == b'w+': |
| 318 | c_mode = AFC_FOPEN_WR | 322 | c_mode = AFC_FOPEN_WR |
| 319 | elif mode == <bytes>'a': | 323 | elif mode == b'a': |
| 320 | c_mode = AFC_FOPEN_APPEND | 324 | c_mode = AFC_FOPEN_APPEND |
| 321 | elif mode == <bytes>'a+': | 325 | elif mode == b'a+': |
| 322 | c_mode = AFC_FOPEN_RDAPPEND | 326 | c_mode = AFC_FOPEN_RDAPPEND |
| 323 | else: | 327 | else: |
| 324 | raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") | 328 | raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'") |
