diff options
| author | 2009-05-08 08:26:38 -0700 | |
|---|---|---|
| committer | 2009-05-08 08:26:38 -0700 | |
| commit | a00db256b55698eea91efab16b6be883246249ca (patch) | |
| tree | 52501080a57f5c933e3888eced92cd7b30b90cae | |
| parent | 2ce660f06cd9399d8aaf3c585130ba6d410b1d17 (diff) | |
| download | libimobiledevice-a00db256b55698eea91efab16b6be883246249ca.tar.gz libimobiledevice-a00db256b55698eea91efab16b6be883246249ca.tar.bz2 | |
file open modes updated
Signed-off-by: Matt Colyer <matt@colyer.name>
| -rw-r--r-- | dev/afccheck.c | 4 | ||||
| -rw-r--r-- | dev/main.c | 8 | ||||
| -rw-r--r-- | 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) | |||
| 53 | iphone_afc_file_t file = NULL; | 53 | iphone_afc_file_t file = NULL; |
| 54 | char path[50]; | 54 | char path[50]; |
| 55 | sprintf(path, "/Buf%i", ((param *) data)->id); | 55 | sprintf(path, "/Buf%i", ((param *) data)->id); |
| 56 | iphone_afc_open_file(((param *) data)->afc, path, IPHONE_AFC_FILE_WRITE, &file); | 56 | iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); |
| 57 | iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); | 57 | iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); |
| 58 | iphone_afc_close_file(((param *) data)->afc, file); | 58 | iphone_afc_close_file(((param *) data)->afc, file); |
| 59 | file = NULL; | 59 | file = NULL; |
| @@ -62,7 +62,7 @@ void check_afc(gpointer data) | |||
| 62 | 62 | ||
| 63 | //now read it | 63 | //now read it |
| 64 | bytes = 0; | 64 | bytes = 0; |
| 65 | iphone_afc_open_file(((param *) data)->afc, path, IPHONE_AFC_FILE_READ, &file); | 65 | iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); |
| 66 | iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); | 66 | iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); |
| 67 | iphone_afc_close_file(((param *) data)->afc, file); | 67 | iphone_afc_close_file(((param *) data)->afc, file); |
| 68 | if (bytes != buffersize) | 68 | if (bytes != buffersize) |
| @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) | |||
| 105 | if (afc) { | 105 | if (afc) { |
| 106 | perform_syncWillStart(phone, control); | 106 | perform_syncWillStart(phone, control); |
| 107 | 107 | ||
| 108 | iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", IPHONE_AFC_FILE_WRITE, &lockfile); | 108 | iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); |
| 109 | if (lockfile) { | 109 | if (lockfile) { |
| 110 | printf("locking file\n"); | 110 | printf("locking file\n"); |
| 111 | iphone_afc_lock_file(afc, lockfile, 2 | 4); | 111 | iphone_afc_lock_file(afc, lockfile, 2 | 4); |
| @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) | |||
| 135 | struct stat stbuf; | 135 | struct stat stbuf; |
| 136 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); | 136 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); |
| 137 | if (IPHONE_E_SUCCESS == | 137 | if (IPHONE_E_SUCCESS == |
| 138 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { | 138 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FOPEN_RDONLY, &my_file) && my_file) { |
| 139 | printf("A file size: %i\n", (int) stbuf.st_size); | 139 | printf("A file size: %i\n", (int) stbuf.st_size); |
| 140 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); | 140 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); |
| 141 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); | 141 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); |
| @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) | |||
| 149 | } else | 149 | } else |
| 150 | printf("couldn't open a file\n"); | 150 | printf("couldn't open a file\n"); |
| 151 | 151 | ||
| 152 | iphone_afc_open_file(afc, "/readme.libiphone.fx", IPHONE_AFC_FILE_WRITE, &my_file); | 152 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); |
| 153 | if (my_file) { | 153 | if (my_file) { |
| 154 | char *outdatafile = strdup("this is a bitchin text file\n"); | 154 | char *outdatafile = strdup("this is a bitchin text file\n"); |
| 155 | iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); | 155 | iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); |
| @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) | |||
| 175 | printf("Failure. (expected unless you have a /renme file on your phone)\n"); | 175 | printf("Failure. (expected unless you have a /renme file on your phone)\n"); |
| 176 | 176 | ||
| 177 | printf("Seek & read\n"); | 177 | printf("Seek & read\n"); |
| 178 | iphone_afc_open_file(afc, "/readme.libiphone.fx", IPHONE_AFC_FILE_READ, &my_file); | 178 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); |
| 179 | if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5)) | 179 | if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5)) |
| 180 | printf("WARN: SEEK DID NOT WORK\n"); | 180 | printf("WARN: SEEK DID NOT WORK\n"); |
| 181 | char *threeletterword = (char *) malloc(sizeof(char) * 5); | 181 | char *threeletterword = (char *) malloc(sizeof(char) * 5); |
diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h index 36b1512..a45319f 100644 --- a/include/libiphone/libiphone.h +++ b/include/libiphone/libiphone.h | |||
| @@ -54,14 +54,12 @@ extern "C" { | |||
| 54 | typedef int16_t iphone_error_t; | 54 | typedef int16_t iphone_error_t; |
| 55 | 55 | ||
| 56 | typedef enum { | 56 | typedef enum { |
| 57 | IPHONE_AFC_FILE_READ = 0x00000001, // seems to be able to read and write files | 57 | AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY |
| 58 | IPHONE_AFC_FILE_WRITE = 0x00000002, // writes and creates a file, blanks it out, etc. | 58 | AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT |
| 59 | IPHONE_AFC_FILE_RW = 0x00000003, // seems to do the same as 2. Might even create the file. | 59 | AFC_FOPEN_WRONLY = 0x00000003, // w O_WRONLY | O_CREAT | O_TRUNC |
| 60 | IPHONE_AFC_FILE_CREAT = 0x00000004, // no idea -- appears to be "write" -- clears file beforehand like 3 | 60 | AFC_FOPEN_WR = 0x00000004, // w+ O_RDWR | O_CREAT | O_TRUNC |
| 61 | IPHONE_AFC_FILE_OP6 = 0x00000006, // no idea yet -- appears to be the same as 5. | 61 | AFC_FOPEN_APPEND = 0x00000005, // a O_WRONLY | O_APPEND | O_CREAT |
| 62 | IPHONE_AFC_FILE_OP1 = 0x00000001, // no idea juuust yet... probably read. | 62 | AFC_FOPEN_RDAPPEND = 0x00000006 // a+ O_RDWR | O_APPEND | O_CREAT |
| 63 | IPHONE_AFC_FILE_OP0 = 0x00000000, | ||
| 64 | IPHONE_AFC_FILE_OP10 = 0x0000000a | ||
| 65 | } iphone_afc_file_mode_t; | 63 | } iphone_afc_file_mode_t; |
| 66 | 64 | ||
| 67 | struct iphone_device_int; | 65 | struct iphone_device_int; |
