Class AfcNativeMethods
Inheritance
Inherited Members
Namespace: iMobileDevice.Afc
Assembly: iMobileDevice-net.dll
Syntax
public class AfcNativeMethods
Methods
afc_client_free(IntPtr)
Frees up an AFC client. If the connection was created by the client itself, the connection will be closed.
Declaration
public static AfcError afc_client_free(IntPtr client)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | client | The client to free. |
Returns
Type | Description |
---|---|
AfcError |
afc_client_new(iDeviceHandle, LockdownServiceDescriptorHandle, out AfcClientHandle)
Makes a connection to the AFC service on the device.
Declaration
public static AfcError afc_client_new(iDeviceHandle device, LockdownServiceDescriptorHandle service, out AfcClientHandle client)
Parameters
Type | Name | Description |
---|---|---|
iDeviceHandle | device | The device to connect to. |
LockdownServiceDescriptorHandle | service | The service descriptor returned by lockdownd_start_service. |
AfcClientHandle | client | Pointer that will be set to a newly allocated afc_client_t upon successful return. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success, AFC_E_INVALID_ARG if device or service is invalid, AFC_E_MUX_ERROR if the connection cannot be established, or AFC_E_NO_MEM if there is a memory allocation problem. |
afc_client_start_service(iDeviceHandle, out AfcClientHandle, String)
Starts a new AFC service on the specified device and connects to it.
Declaration
public static AfcError afc_client_start_service(iDeviceHandle device, out AfcClientHandle client, string label)
Parameters
Type | Name | Description |
---|---|---|
iDeviceHandle | device | The device to connect to. |
AfcClientHandle | client | Pointer that will point to a newly allocated afc_client_t upon successful return. Must be freed using afc_client_free() after use. |
System.String | label | The label to use for communication. Usually the program name. Pass NULL to disable sending the label in requests to lockdownd. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success, or an AFC_E_* error code otherwise. |
afc_dictionary_free(IntPtr)
Frees up a char dictionary as returned by some AFC functions.
Declaration
public static AfcError afc_dictionary_free(IntPtr dictionary)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | dictionary | The char array terminated by an empty string. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_file_close(AfcClientHandle, UInt64)
Closes a file on the device.
Declaration
public static AfcError afc_file_close(AfcClientHandle client, ulong handle)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to close the file with. |
System.UInt64 | handle | File handle of a previously opened file. |
Returns
Type | Description |
---|---|
AfcError |
afc_file_lock(AfcClientHandle, UInt64, AfcLockOp)
Locks or unlocks a file on the device. Makes use of flock on the device.
Declaration
public static AfcError afc_file_lock(AfcClientHandle client, ulong handle, AfcLockOp operation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to lock the file with. |
System.UInt64 | handle | File handle of a previously opened file. |
AfcLockOp | operation | the lock or unlock operation to perform, this is one of AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock), or AFC_LOCK_UN (unlock). |
Returns
Type | Description |
---|---|
AfcError |
afc_file_open(AfcClientHandle, String, AfcFileMode, ref UInt64)
Opens a file on the device.
Declaration
public static AfcError afc_file_open(AfcClientHandle client, string filename, AfcFileMode fileMode, ref ulong handle)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to open the file. |
System.String | filename | The file to open. (must be a fully-qualified path) |
AfcFileMode | fileMode | |
System.UInt64 | handle | Pointer to a uint64_t that will hold the handle of the file |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_file_read(AfcClientHandle, UInt64, Byte[], UInt32, ref UInt32)
Attempts to the read the given number of bytes from the given file.
Declaration
public static AfcError afc_file_read(AfcClientHandle client, ulong handle, byte[] data, uint length, ref uint bytesRead)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The relevant AFC client |
System.UInt64 | handle | File handle of a previously opened file |
System.Byte[] | data | The pointer to the memory region to store the read data |
System.UInt32 | length | The number of bytes to read |
System.UInt32 | bytesRead |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_file_seek(AfcClientHandle, UInt64, Int64, Int32)
Seeks to a given position of a pre-opened file on the device.
Declaration
public static AfcError afc_file_seek(AfcClientHandle client, ulong handle, long offset, int whence)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to seek to the position. |
System.UInt64 | handle | File handle of a previously opened. |
System.Int64 | offset | Seek offset. |
System.Int32 | whence | Seeking direction, one of SEEK_SET, SEEK_CUR, or SEEK_END. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_file_tell(AfcClientHandle, UInt64, ref UInt64)
Returns current position in a pre-opened file on the device.
Declaration
public static AfcError afc_file_tell(AfcClientHandle client, ulong handle, ref ulong position)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use. |
System.UInt64 | handle | File handle of a previously opened file. |
System.UInt64 | position | Position in bytes of indicator |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_file_truncate(AfcClientHandle, UInt64, UInt64)
Sets the size of a file on the device.
Declaration
public static AfcError afc_file_truncate(AfcClientHandle client, ulong handle, ulong newsize)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to set the file size. |
System.UInt64 | handle | File handle of a previously opened file. |
System.UInt64 | newsize | The size to set the file to. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
Remarks
This function is more akin to ftruncate than truncate, and truncate calls would have to open the file before calling this, sadly.
afc_file_write(AfcClientHandle, UInt64, Byte[], UInt32, ref UInt32)
Writes a given number of bytes to a file.
Declaration
public static AfcError afc_file_write(AfcClientHandle client, ulong handle, byte[] data, uint length, ref uint bytesWritten)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to write to the file. |
System.UInt64 | handle | File handle of previously opened file. |
System.Byte[] | data | The data to write to the file. |
System.UInt32 | length | How much data to write. |
System.UInt32 | bytesWritten |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_get_device_info(AfcClientHandle, out ReadOnlyCollection<String>)
Declaration
public static AfcError afc_get_device_info(AfcClientHandle client, out ReadOnlyCollection<string> deviceInformation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | |
System.Collections.ObjectModel.ReadOnlyCollection<System.String> | deviceInformation |
Returns
Type | Description |
---|---|
AfcError |
afc_get_device_info(AfcClientHandle, out IntPtr)
Get device information for a connected client. The device information returned is the device model as well as the free space, the total capacity and blocksize on the accessed disk partition.
Declaration
public static AfcError afc_get_device_info(AfcClientHandle client, out IntPtr deviceInformation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to get device info for. |
System.IntPtr | deviceInformation |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_get_device_info_key(AfcClientHandle, String, out IntPtr)
Get a specific key of the device info list for a client connection. Known key values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize. This is a helper function for afc_get_device_info().
Declaration
public static AfcError afc_get_device_info_key(AfcClientHandle client, string key, out IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to get device info for. |
System.String | key | The key to get the value of. |
System.IntPtr | value | The value for the key if successful or NULL otherwise. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_get_device_info_key(AfcClientHandle, String, out String)
Declaration
public static AfcError afc_get_device_info_key(AfcClientHandle client, string key, out string value)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | |
System.String | key | |
System.String | value |
Returns
Type | Description |
---|---|
AfcError |
afc_get_file_info(AfcClientHandle, String, out ReadOnlyCollection<String>)
Declaration
public static AfcError afc_get_file_info(AfcClientHandle client, string filename, out ReadOnlyCollection<string> fileInformation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | |
System.String | filename | |
System.Collections.ObjectModel.ReadOnlyCollection<System.String> | fileInformation |
Returns
Type | Description |
---|---|
AfcError |
afc_get_file_info(AfcClientHandle, String, out IntPtr)
Gets information about a specific file.
Declaration
public static AfcError afc_get_file_info(AfcClientHandle client, string filename, out IntPtr fileInformation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to get the information of the file. |
System.String | filename | The fully-qualified path to the file. |
System.IntPtr | fileInformation |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_make_directory(AfcClientHandle, String)
Creates a directory on the device.
Declaration
public static AfcError afc_make_directory(AfcClientHandle client, string path)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to make a directory. |
System.String | path | The directory's path. (must be a fully-qualified path, I assume all other mkdir restrictions apply as well) |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_make_link(AfcClientHandle, AfcLinkType, String, String)
Creates a hard link or symbolic link on the device.
Declaration
public static AfcError afc_make_link(AfcClientHandle client, AfcLinkType linktype, string target, string linkname)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use for making a link |
AfcLinkType | linktype | 1 = hard link, 2 = symlink |
System.String | target | The file to be linked. |
System.String | linkname | The name of link. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_read_directory(AfcClientHandle, String, out ReadOnlyCollection<String>)
Declaration
public static AfcError afc_read_directory(AfcClientHandle client, string path, out ReadOnlyCollection<string> directoryInformation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | |
System.String | path | |
System.Collections.ObjectModel.ReadOnlyCollection<System.String> | directoryInformation |
Returns
Type | Description |
---|---|
AfcError |
afc_read_directory(AfcClientHandle, String, out IntPtr)
Gets a directory listing of the directory requested.
Declaration
public static AfcError afc_read_directory(AfcClientHandle client, string path, out IntPtr directoryInformation)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to get a directory listing from. |
System.String | path | The directory for listing. (must be a fully-qualified path) |
System.IntPtr | directoryInformation |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_remove_path(AfcClientHandle, String)
Deletes a file or directory.
Declaration
public static AfcError afc_remove_path(AfcClientHandle client, string path)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use. |
System.String | path | The path to delete. (must be a fully-qualified path) |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_remove_path_and_contents(AfcClientHandle, String)
Deletes a file or directory including possible contents.
Declaration
public static AfcError afc_remove_path_and_contents(AfcClientHandle client, string path)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use. |
System.String | path | The path to delete. (must be a fully-qualified path) |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
Remarks
Only available in iOS 6 and later.
afc_rename_path(AfcClientHandle, String, String)
Renames a file or directory on the device.
Declaration
public static AfcError afc_rename_path(AfcClientHandle client, string from, string to)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to have rename. |
System.String | from | The name to rename from. (must be a fully-qualified path) |
System.String | to | The new name. (must also be a fully-qualified path) |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_set_file_time(AfcClientHandle, String, UInt64)
Sets the modification time of a file on the device.
Declaration
public static AfcError afc_set_file_time(AfcClientHandle client, string path, ulong mtime)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to set the file size. |
System.String | path | Path of the file for which the modification time should be set. |
System.UInt64 | mtime | The modification time to set in nanoseconds since epoch. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |
afc_truncate(AfcClientHandle, String, UInt64)
Sets the size of a file on the device without prior opening it.
Declaration
public static AfcError afc_truncate(AfcClientHandle client, string path, ulong newsize)
Parameters
Type | Name | Description |
---|---|---|
AfcClientHandle | client | The client to use to set the file size. |
System.String | path | The path of the file to be truncated. |
System.UInt64 | newsize | The size to set the file to. |
Returns
Type | Description |
---|---|
AfcError | AFC_E_SUCCESS on success or an AFC_E_* error value. |