From ff0df3d5e258d7a2a9381afdc15fd80f69f38be4 Mon Sep 17 00:00:00 2001 From: Perry Clarke Date: Fri, 23 Mar 2018 01:19:04 +0100 Subject: Display CFBundleIdentifier for .app folder installs --- src/ideviceinstaller.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index 8b40bb3..28b98ec 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c @@ -958,6 +958,52 @@ run_again: printf("Uploading %s package contents... ", basename(appid)); afc_upload_dir(afc, appid, pkgname); printf("DONE.\n"); + + /* extract the CFBundleIdentifier from the package */ + + /* construct full filename to Info.plist */ + char *filename = (char*)malloc(strlen(appid)+10+1); + strcpy(filename, appid); + strcat(filename, "/Info.plist"); + + struct stat st; + FILE *fp = NULL; + + if (stat(filename, &st) == -1 || (fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "ERROR: could not locate %s in app!\n", filename); + free(filename); + goto leave_cleanup; + } + size_t filesize = st.st_size; + char *ibuf = malloc(filesize * sizeof(char)); + size_t amount = fread(ibuf, 1, filesize, fp); + if (amount != filesize) { + fprintf(stderr, "ERROR: could not read %ld bytes from %s\n", filesize, filename); + free(filename); + goto leave_cleanup; + } + fclose(fp); + free(filename); + + plist_t info = NULL; + if (memcmp(ibuf, "bplist00", 8) == 0) { + plist_from_bin(ibuf, filesize, &info); + } else { + plist_from_xml(ibuf, filesize, &info); + } + free(ibuf); + + if (!info) { + fprintf(stderr, "ERROR: could not parse Info.plist!\n"); + goto leave_cleanup; + } + + plist_t bname = plist_dict_get_item(info, "CFBundleIdentifier"); + if (bname) { + plist_get_string_val(bname, &bundleidentifier); + } + plist_free(info); + info = NULL; } else { zf = zip_open(appid, 0, &errp); if (!zf) { -- cgit v1.1-32-gdbae