summaryrefslogtreecommitdiffstats
path: root/src/AFC.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-10-30 18:07:20 +0100
committerGravatar Matt Colyer2009-11-02 20:52:55 -0800
commit549f4389e3009d9f78b94d4a3570e29f428968ab (patch)
treef5de57c8a5a3e54f634287743f0b638786b674ec /src/AFC.c
parentd6226d01ce5bd00a85310061fb33d0510ecd7564 (diff)
downloadlibimobiledevice-549f4389e3009d9f78b94d4a3570e29f428968ab.tar.gz
libimobiledevice-549f4389e3009d9f78b94d4a3570e29f428968ab.tar.bz2
AFC: new function afc_set_file_time
This function allows to set the modification time of a file. The time value needs to be specified as nanoseconds since epoch. [#81 state:resolved] Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/AFC.c')
-rw-r--r--src/AFC.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/AFC.c b/src/AFC.c
index ba436e7..54b3795 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -1213,3 +1213,46 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
1213 1213
1214 return ret; 1214 return ret;
1215} 1215}
1216
1217/** Sets the modification time of a file on the phone.
1218 *
1219 * @param client The client to use to set the file size.
1220 * @param path Path of the file for which the modification time should be set.
1221 * @param mtime The modification time to set in nanoseconds since epoch.
1222 *
1223 * @return AFC_E_SUCCESS if everything went well, AFC_E_INVALID_ARGUMENT
1224 * if arguments are NULL or invalid, AFC_E_NOT_ENOUGH_DATA otherwise.
1225 */
1226afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
1227{
1228 char *response = NULL;
1229 char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
1230 int bytes = 0;
1231 afc_error_t ret = AFC_E_UNKNOWN_ERROR;
1232
1233 if (!client || !path || !client->afc_packet || !client->connection)
1234 return AFC_E_INVALID_ARGUMENT;
1235
1236 afc_lock(client);
1237
1238 // Send command
1239 memcpy(send, &mtime, 8);
1240 memcpy(send + 8, path, strlen(path) + 1);
1241 client->afc_packet->entire_length = client->afc_packet->this_length = 0;
1242 client->afc_packet->operation = AFC_OP_SET_FILE_TIME;
1243 bytes = afc_dispatch_packet(client, send, 8 + strlen(path) + 1);
1244 free(send);
1245 if (bytes <= 0) {
1246 afc_unlock(client);
1247 return AFC_E_NOT_ENOUGH_DATA;
1248 }
1249 // Receive response
1250 ret = afc_receive_data(client, &response, &bytes);
1251 if (response)
1252 free(response);
1253
1254 afc_unlock(client);
1255
1256 return ret;
1257}
1258