From 28e1428880e10bbdf38cd1bec4085c0657cfc589 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 21 Apr 2009 17:12:13 +0200 Subject: [PATCH] file open modes updated --- dev/afccheck.c | 4 ++-- dev/main.c | 8 ++++---- include/libiphone/libiphone.h | 14 ++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/dev/afccheck.c b/dev/afccheck.c index 0ff420a..152a8df 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -53,7 +53,7 @@ void check_afc(gpointer data) iphone_afc_file_t file = NULL; char path[50]; sprintf(path, "/Buf%i", ((param *) data)->id); - iphone_afc_open_file(((param *) data)->afc, path, IPHONE_AFC_FILE_WRITE, &file); + iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); iphone_afc_close_file(((param *) data)->afc, file); file = NULL; @@ -62,7 +62,7 @@ void check_afc(gpointer data) //now read it bytes = 0; - iphone_afc_open_file(((param *) data)->afc, path, IPHONE_AFC_FILE_READ, &file); + iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); iphone_afc_close_file(((param *) data)->afc, file); if (bytes != buffersize) diff --git a/dev/main.c b/dev/main.c index 8ba11e1..218ea6c 100644 --- a/dev/main.c +++ b/dev/main.c @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) perform_notification(phone, control, NP_SYNC_WILL_START); - iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", IPHONE_AFC_FILE_WRITE, &lockfile); + iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); if (lockfile) { printf("locking file\n"); iphone_afc_lock_file(afc, lockfile, 2 | 4); @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) struct stat stbuf; iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); if (IPHONE_E_SUCCESS == - iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { + iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FOPEN_RDONLY, &my_file) && my_file) { printf("A file size: %i\n", (int) stbuf.st_size); char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) } else printf("couldn't open a file\n"); - iphone_afc_open_file(afc, "/readme.libiphone.fx", IPHONE_AFC_FILE_WRITE, &my_file); + iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); if (my_file) { char *outdatafile = strdup("this is a bitchin text file\n"); iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); @@ -191,7 +191,7 @@ int main(int argc, char *argv[]) printf("Failure. (expected unless you have a /renme file on your phone)\n"); printf("Seek & read\n"); - iphone_afc_open_file(afc, "/readme.libiphone.fx", IPHONE_AFC_FILE_READ, &my_file); + iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5)) printf("WARN: SEEK DID NOT WORK\n"); char *threeletterword = (char *) malloc(sizeof(char) * 5); diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h index 08896c7..6427f29 100644 --- a/include/libiphone/libiphone.h +++ b/include/libiphone/libiphone.h @@ -54,14 +54,12 @@ extern "C" { typedef int16_t iphone_error_t; typedef enum { - IPHONE_AFC_FILE_READ = 0x00000001, // seems to be able to read and write files - IPHONE_AFC_FILE_WRITE = 0x00000002, // writes and creates a file, blanks it out, etc. - IPHONE_AFC_FILE_RW = 0x00000003, // seems to do the same as 2. Might even create the file. - IPHONE_AFC_FILE_CREAT = 0x00000004, // no idea -- appears to be "write" -- clears file beforehand like 3 - IPHONE_AFC_FILE_OP6 = 0x00000006, // no idea yet -- appears to be the same as 5. - IPHONE_AFC_FILE_OP1 = 0x00000001, // no idea juuust yet... probably read. - IPHONE_AFC_FILE_OP0 = 0x00000000, - IPHONE_AFC_FILE_OP10 = 0x0000000a + AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY + AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT + AFC_FOPEN_WRONLY = 0x00000003, // w O_WRONLY | O_CREAT | O_TRUNC + AFC_FOPEN_WR = 0x00000004, // w+ O_RDWR | O_CREAT | O_TRUNC + AFC_FOPEN_APPEND = 0x00000005, // a O_WRONLY | O_APPEND | O_CREAT + AFC_FOPEN_RDAPPEND = 0x00000006 // a+ O_RDWR | O_APPEND | O_CREAT } iphone_afc_file_mode_t; struct iphone_device_int; -- 1.6.0.4