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)
downloadlibplist-020d7c23b17956098379140f1f0047ae8e78df1b.tar.gz
libplist-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[]) {
}
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 {