summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Perry Clarke2018-03-23 01:19:04 +0100
committerGravatar Nikias Bassen2018-03-23 01:19:04 +0100
commitff0df3d5e258d7a2a9381afdc15fd80f69f38be4 (patch)
tree16166c835dd398aa31887b7adae8e03183dc38f9
parentf07a9a0a4b844d12f70569ce8ca7c555ddb3cad8 (diff)
downloadideviceinstaller-ff0df3d5e258d7a2a9381afdc15fd80f69f38be4.tar.gz
ideviceinstaller-ff0df3d5e258d7a2a9381afdc15fd80f69f38be4.tar.bz2
Display CFBundleIdentifier for .app folder installs
-rw-r--r--src/ideviceinstaller.c46
1 files changed, 46 insertions, 0 deletions
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) {