summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libimobiledevice/afc.h12
-rw-r--r--src/afc.c24
2 files changed, 36 insertions, 0 deletions
diff --git a/include/libimobiledevice/afc.h b/include/libimobiledevice/afc.h
index 667fd63..b045554 100644
--- a/include/libimobiledevice/afc.h
+++ b/include/libimobiledevice/afc.h
@@ -338,6 +338,18 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
338 */ 338 */
339afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime); 339afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime);
340 340
341/**
342 * Deletes a file or directory including possible contents.
343 *
344 * @param client The client to use.
345 * @param path The path to delete. (must be a fully-qualified path)
346 * @since libimobiledevice 1.1.7
347 * @note Only available in iOS 6 and later.
348 *
349 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
350 */
351afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path);
352
341/* Helper functions */ 353/* Helper functions */
342 354
343/** 355/**
diff --git a/src/afc.c b/src/afc.c
index 50ac5bf..2e2d62c 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -998,6 +998,30 @@ afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mt
998 return ret; 998 return ret;
999} 999}
1000 1000
1001afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path)
1002{
1003 uint32_t bytes = 0;
1004 afc_error_t ret = AFC_E_UNKNOWN_ERROR;
1005
1006 if (!client || !path || !client->afc_packet || !client->parent)
1007 return AFC_E_INVALID_ARG;
1008
1009 afc_lock(client);
1010
1011 /* Send command */
1012 ret = afc_dispatch_packet(client, AFC_OP_REMOVE_PATH_AND_CONTENTS, path, strlen(path)+1, NULL, 0, &bytes);
1013 if (ret != AFC_E_SUCCESS) {
1014 afc_unlock(client);
1015 return AFC_E_NOT_ENOUGH_DATA;
1016 }
1017 /* Receive response */
1018 ret = afc_receive_data(client, NULL, &bytes);
1019
1020 afc_unlock(client);
1021
1022 return ret;
1023}
1024
1001afc_error_t afc_dictionary_free(char **dictionary) 1025afc_error_t afc_dictionary_free(char **dictionary)
1002{ 1026{
1003 int i = 0; 1027 int i = 0;