afc.h File Reference

## Description

Access the filesystem on the device.

## Macros

#define | AFC_SERVICE_NAME "com.apple.afc"
| Service identifier passed to lockdownd_start_service() to start the AFC service.

## Typedefs

typedef afc_client_private * | afc_client_t
| The client handle.

## Enumerations

enum

afc_error_t {
AFC_E_SUCCESS = 0 ,
AFC_E_UNKNOWN_ERROR = 1 ,
AFC_E_OP_HEADER_INVALID = 2 ,
AFC_E_NO_RESOURCES = 3 ,
AFC_E_READ_ERROR = 4 ,
AFC_E_WRITE_ERROR = 5 ,
AFC_E_UNKNOWN_PACKET_TYPE = 6 ,
AFC_E_INVALID_ARG = 7 ,
AFC_E_OBJECT_NOT_FOUND = 8 ,
AFC_E_OBJECT_IS_DIR = 9 ,
AFC_E_PERM_DENIED = 10 ,
AFC_E_SERVICE_NOT_CONNECTED = 11 ,
AFC_E_OP_TIMEOUT = 12 ,
AFC_E_TOO_MUCH_DATA = 13 ,
AFC_E_END_OF_DATA = 14 ,
AFC_E_OP_NOT_SUPPORTED = 15 ,
AFC_E_OBJECT_EXISTS = 16 ,
AFC_E_OBJECT_BUSY = 17 ,
AFC_E_NO_SPACE_LEFT = 18 ,
AFC_E_OP_WOULD_BLOCK = 19 ,
AFC_E_IO_ERROR = 20 ,
AFC_E_OP_INTERRUPTED = 21 ,
AFC_E_OP_IN_PROGRESS = 22 ,
AFC_E_INTERNAL_ERROR = 23 ,
AFC_E_MUX_ERROR = 30 ,
AFC_E_NO_MEM = 31 ,
AFC_E_NOT_ENOUGH_DATA = 32 ,
AFC_E_DIR_NOT_EMPTY = 33 ,
AFC_E_FORCE_SIGNED_TYPE = -1
}

| Error Codes.
enum | afc_file_mode_t { AFC_FOPEN_RDONLY = 0x00000001 , AFC_FOPEN_RW = 0x00000002 , AFC_FOPEN_WRONLY = 0x00000003 , AFC_FOPEN_WR = 0x00000004 , AFC_FOPEN_APPEND = 0x00000005 , AFC_FOPEN_RDAPPEND = 0x00000006 }
| Flags for afc_file_open. More...
enum | afc_link_type_t { AFC_HARDLINK = 1 , AFC_SYMLINK = 2 }
| Type of link for afc_make_link() calls.
enum | afc_lock_op_t { AFC_LOCK_SH = 1 | 4 , AFC_LOCK_EX = 2 | 4 , AFC_LOCK_UN = 8 | 4 }
| Lock operation flags. More...

## Functions

afc_error_t | afc_client_new (idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client)
| Makes a connection to the AFC service on the device.
afc_error_t | afc_client_start_service (idevice_t device, afc_client_t *client, const char *label)
| Starts a new AFC service on the specified device and connects to it.
afc_error_t | afc_client_free (afc_client_t client)
| Frees up an AFC client.
afc_error_t | afc_get_device_info (afc_client_t client, char ***device_information)
| Get device information for a connected client.
afc_error_t | afc_get_device_info_plist (afc_client_t client, plist_t *device_information)
| Get device information for a connected client.
afc_error_t | afc_read_directory (afc_client_t client, const char *path, char ***directory_information)
| Gets a directory listing of the directory requested.
afc_error_t | afc_get_file_info (afc_client_t client, const char *path, char ***file_information)
| Gets information about a specific file.
afc_error_t | afc_get_file_info_plist (afc_client_t client, const char *path, plist_t *file_information)
| Gets information about a specific file.
afc_error_t | afc_file_open (afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle)
| Opens a file on the device.
afc_error_t | afc_file_close (afc_client_t client, uint64_t handle)
| Closes a file on the device.
afc_error_t | afc_file_lock (afc_client_t client, uint64_t handle, afc_lock_op_t operation)
| Locks or unlocks a file on the device.
afc_error_t | afc_file_read (afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read)
| Attempts to the read the given number of bytes from the given file.
afc_error_t | afc_file_write (afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written)
| Writes a given number of bytes to a file.
afc_error_t | afc_file_seek (afc_client_t client, uint64_t handle, int64_t offset, int whence)
| Seeks to a given position of a pre-opened file on the device.
afc_error_t | afc_file_tell (afc_client_t client, uint64_t handle, uint64_t *position)
| Returns current position in a pre-opened file on the device.
afc_error_t | afc_file_truncate (afc_client_t client, uint64_t handle, uint64_t newsize)
| Sets the size of a file on the device.
afc_error_t | afc_remove_path (afc_client_t client, const char *path)
| Deletes a file or directory.
afc_error_t | afc_rename_path (afc_client_t client, const char *from, const char *to)
| Renames a file or directory on the device.
afc_error_t | afc_make_directory (afc_client_t client, const char *path)
| Creates a directory on the device.
afc_error_t | afc_truncate (afc_client_t client, const char *path, uint64_t newsize)
| Sets the size of a file on the device without prior opening it.
afc_error_t | afc_make_link (afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
| Creates a hard link or symbolic link on the device.
afc_error_t | afc_set_file_time (afc_client_t client, const char *path, uint64_t mtime)
| Sets the modification time of a file on the device.
afc_error_t | afc_remove_path_and_contents (afc_client_t client, const char *path)
| Deletes a file or directory including possible contents.
afc_error_t | afc_get_device_info_key (afc_client_t client, const char *key, char **value)
| Get a specific key of the device info list for a client connection.
afc_error_t | afc_dictionary_free (char **dictionary)
| Frees up a char dictionary as returned by some AFC functions.
const char * | afc_strerror (afc_error_t err)
| Gets a readable error string for a given AFC error code.