From 020d7c23b17956098379140f1f0047ae8e78df1b Mon Sep 17 00:00:00 2001 From: Zach C Date: Sun, 10 Aug 2008 17:24:32 -0700 Subject: 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 --- src/main.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/main.c') 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[]) { } free_dictionary(dirs); + dirs = afc_get_devinfo(afc); + if (dirs) { + for (i = 0; strcmp(dirs[i], ""); i+=2) { + printf("%s: %s\n", dirs[i], dirs[i+1]); + } + } + AFCFile *my_file = afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FILE_READ); if (my_file) { printf("A file size: %i\n", my_file->size); @@ -108,12 +115,25 @@ int main(int argc, char *argv[]) { printf("Deleting a file...\n"); bytes = afc_delete_file(afc, "/delme"); if (bytes) printf("Success.\n"); - else printf("Failure.\n"); + else printf("Failure. (expected unless you have a /delme file on your phone)\n"); printf("Renaming a file...\n"); bytes = afc_rename_file(afc, "/renme", "/renme2"); if (bytes > 0) printf("Success.\n"); - else printf("Failure.\n"); + else printf("Failure. (expected unless you have a /renme file on your phone)\n"); + + printf("Seek & read\n"); + my_file = afc_open_file(afc, "/readme.libiphone.fx", AFC_FILE_READ); + bytes = afc_seek_file(afc, my_file, 5); + if (!bytes) printf("WARN: SEEK DID NOT WORK\n"); + char *threeletterword = (char*)malloc(sizeof(char) * 5); + bytes = afc_read_file(afc, my_file, threeletterword, 3); + threeletterword[3] = '\0'; + if (bytes > 0) printf("Result: %s\n", threeletterword); + else printf("Couldn't read!\n"); + free(threeletterword); + afc_close_file(afc, my_file); + } afc_disconnect(afc); } else { -- cgit v1.1-32-gdbae