summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorGravatar Zach C2008-08-10 17:24:32 -0700
committerGravatar Matthew Colyer2008-08-10 17:24:32 -0700
commit020d7c23b17956098379140f1f0047ae8e78df1b (patch)
tree310d14b340309ba79ed5b8c15fe0e39d99c2f207 /src/main.c
parent4c3f86499f8dfe344fb5f92b805e8c090290a79e (diff)
downloadlibimobiledevice-020d7c23b17956098379140f1f0047ae8e78df1b.tar.gz
libimobiledevice-020d7c23b17956098379140f1f0047ae8e78df1b.tar.bz2
Adds seeking, directory creation and improves file writing. Also various other cleanups.
Implements creating directories as well as writing and deleting files in iFuse. Signed-off-by: Matthew Colyer <mcolyer@mcolyer-laptop.(none)>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index fd2a0d4..91bb48c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,6 +80,13 @@ int main(int argc, char *argv[]) {
80 } 80 }
81 81
82 free_dictionary(dirs); 82 free_dictionary(dirs);
83 dirs = afc_get_devinfo(afc);
84 if (dirs) {
85 for (i = 0; strcmp(dirs[i], ""); i+=2) {
86 printf("%s: %s\n", dirs[i], dirs[i+1]);
87 }
88 }
89
83 AFCFile *my_file = afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FILE_READ); 90 AFCFile *my_file = afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FILE_READ);
84 if (my_file) { 91 if (my_file) {
85 printf("A file size: %i\n", my_file->size); 92 printf("A file size: %i\n", my_file->size);
@@ -108,12 +115,25 @@ int main(int argc, char *argv[]) {
108 printf("Deleting a file...\n"); 115 printf("Deleting a file...\n");
109 bytes = afc_delete_file(afc, "/delme"); 116 bytes = afc_delete_file(afc, "/delme");
110 if (bytes) printf("Success.\n"); 117 if (bytes) printf("Success.\n");
111 else printf("Failure.\n"); 118 else printf("Failure. (expected unless you have a /delme file on your phone)\n");
112 119
113 printf("Renaming a file...\n"); 120 printf("Renaming a file...\n");
114 bytes = afc_rename_file(afc, "/renme", "/renme2"); 121 bytes = afc_rename_file(afc, "/renme", "/renme2");
115 if (bytes > 0) printf("Success.\n"); 122 if (bytes > 0) printf("Success.\n");
116 else printf("Failure.\n"); 123 else printf("Failure. (expected unless you have a /renme file on your phone)\n");
124
125 printf("Seek & read\n");
126 my_file = afc_open_file(afc, "/readme.libiphone.fx", AFC_FILE_READ);
127 bytes = afc_seek_file(afc, my_file, 5);
128 if (!bytes) printf("WARN: SEEK DID NOT WORK\n");
129 char *threeletterword = (char*)malloc(sizeof(char) * 5);
130 bytes = afc_read_file(afc, my_file, threeletterword, 3);
131 threeletterword[3] = '\0';
132 if (bytes > 0) printf("Result: %s\n", threeletterword);
133 else printf("Couldn't read!\n");
134 free(threeletterword);
135 afc_close_file(afc, my_file);
136
117 } 137 }
118 afc_disconnect(afc); 138 afc_disconnect(afc);
119 } else { 139 } else {