diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 24 |
1 files changed, 22 insertions, 2 deletions
| @@ -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 { |
