diff options
| -rw-r--r-- | include/libiphone/afc.h | 3 | ||||
| -rw-r--r-- | src/AFC.c | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index 651621e..77b6f0e 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h | |||
| @@ -106,6 +106,9 @@ afc_error_t afc_make_directory(afc_client_t client, const char *dir); | |||
| 106 | afc_error_t afc_truncate(afc_client_t client, const char *path, off_t newsize); | 106 | afc_error_t afc_truncate(afc_client_t client, const char *path, off_t newsize); |
| 107 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); | 107 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); |
| 108 | 108 | ||
| 109 | /* Helper functions */ | ||
| 110 | char * afc_get_device_info_field(afc_client_t client, const char *field); | ||
| 111 | |||
| 109 | #ifdef __cplusplus | 112 | #ifdef __cplusplus |
| 110 | } | 113 | } |
| 111 | #endif | 114 | #endif |
| @@ -468,6 +468,35 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***infos) | |||
| 468 | return ret; | 468 | return ret; |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | /** Get a specific field of the device info for a client connection to phone. | ||
| 472 | * Known values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize. This is | ||
| 473 | * a helper function for afc_get_device_info(). | ||
| 474 | * | ||
| 475 | * @param client The client to get device info for. | ||
| 476 | * @param field The field to get the information for | ||
| 477 | * | ||
| 478 | * @return A char * or NULL if there was an error. | ||
| 479 | */ | ||
| 480 | char * afc_get_device_info_field(afc_client_t client, const char *field) | ||
| 481 | { | ||
| 482 | char *ret = NULL; | ||
| 483 | char **kvps, **ptr; | ||
| 484 | |||
| 485 | if (field == NULL || afc_get_device_info(client, &kvps) != AFC_E_SUCCESS) | ||
| 486 | return NULL; | ||
| 487 | |||
| 488 | for (ptr = kvps; *ptr; ptr++) { | ||
| 489 | if (!strcmp(*ptr, field)) { | ||
| 490 | ret = strdup(*(ptr+1)); | ||
| 491 | break; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | |||
| 495 | g_strfreev(kvps); | ||
| 496 | |||
| 497 | return ret; | ||
| 498 | } | ||
| 499 | |||
| 471 | /** Deletes a file or directory. | 500 | /** Deletes a file or directory. |
| 472 | * | 501 | * |
| 473 | * @param client The client to use. | 502 | * @param client The client to use. |
