Changeset 137 for trunk/launch/launch/main.c
- Timestamp:
- 04/11/03 23:44:21 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/launch/launch/main.c
r127 r137 56 56 const char *APP_NAME; 57 57 58 #define VERSION "1.0b 2"58 #define VERSION "1.0b3" 59 59 60 60 #define STRBUF_LEN 1024 … … 665 665 strncpy(tmpBuffer, (char *)&info.creator, 4); printf("\tcreator: '%s'\n", tmpBuffer); 666 666 } 667 if (info.flags & kLSItemInfoIsPackage || 668 info.flags & kLSItemInfoIsApplication && info.flags & kLSItemInfoIsNativeApp) { 667 if (info.flags & kLSItemInfoIsPackage || info.flags & kLSItemInfoIsApplication) { 669 668 // a package, or possibly a native app with a 'plst' resource 670 669 CFBundleRef bundle = CFBundleCreate(NULL, url); 671 CFStringRef bundleID; 672 if (bundle == NULL) { // OS X bug causes this to fail when it shouldn't, so just note it, don't die 673 if (info.flags & kLSItemInfoIsApplication) printf("\t[can't access CFBundle for application]\n"); 670 CFStringRef bundleID = NULL; 671 CFStringRef appVersion = NULL; 672 UInt32 intVersion = 0; 673 if (bundle == NULL && (info.flags & kLSItemInfoIsApplication)) { 674 FSRef fsr; 675 if (info.flags & kLSItemInfoIsPackage || !CFURLGetFSRef(url, &fsr)) { 676 printf("\t[can't access CFBundle for application]\n"); 677 } else { // OS X bug causes this to fail when it shouldn't, so fake it 678 SInt16 resFork = FSOpenResFile(&fsr, fsRdPerm); 679 OSStatus err = ResError(); 680 if (err != noErr) { 681 printf("\t[can't open resource fork: %s]\n", osstatusstr(err)); 682 } else { 683 Handle h = Get1Resource('plst', 0); 684 if ( (err = ResError()) != noErr || h == NULL) { 685 if (err != noErr && err != resNotFound) osstatusexit(err, "unable to read 'plst' 0 resource"); 686 } else { 687 CFDataRef plstData = CFDataCreate(NULL, *h, GetHandleSize(h)); 688 CFStringRef error; 689 CFPropertyListRef infoPlist = CFPropertyListCreateFromXMLData(NULL, plstData, kCFPropertyListImmutable, &error); 690 if (infoPlist == NULL) { 691 CFStringGetCString(error, tmpBuffer, STRBUF_LEN, CFStringGetSystemEncoding()); 692 printf("\t['plst' 0 resource invalid: %s]\n", tmpBuffer); 693 CFRelease(error); 694 } else { 695 // mimic CFBundle logic below 696 bundleID = CFDictionaryGetValue(infoPlist, kCFBundleIdentifierKey); 697 if (bundleID != NULL) CFRetain(bundleID); 698 CFStringRef appVersion = CFDictionaryGetValue(infoPlist, CFSTR("CFBundleShortVersionString")); 699 if (appVersion == NULL) 700 appVersion = CFDictionaryGetValue(infoPlist, kCFBundleVersionKey); 701 if (appVersion != NULL) CFRetain(appVersion); 702 CFRelease(infoPlist); 703 } 704 } 705 VersRecHndl vers = (VersRecHndl)Get1Resource('vers', 1); 706 if ( (err = ResError()) != noErr || vers == NULL) { 707 if (err != noErr && err != resNotFound) osstatusexit(err, "unable to read 'vers' 1 resource"); 708 } else { 709 if (appVersion == NULL) { // prefer 'plst' version 710 appVersion = CFStringCreateWithPascalString(NULL, vers[0]->shortVersion, CFStringGetSystemEncoding()); // XXX use country code instead? 711 } 712 intVersion = ((NumVersionVariant)vers[0]->numericVersion).whole; 713 } 714 CloseResFile(resFork); 715 } 716 } 674 717 } else { 675 718 bundleID = CFBundleGetIdentifier(bundle); 676 if (bundleID != NULL) { 677 CFStringGetCString(bundleID, tmpBuffer, STRBUF_LEN, CFStringGetSystemEncoding()); 678 printf("\tbundle ID: %s\n", tmpBuffer); 679 } 719 if (bundleID != NULL) CFRetain(bundleID); 680 720 // prefer a short version string, e.g. "1.0 Beta" instead of "51" for Safari 681 721 CFStringRef appVersion = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("CFBundleShortVersionString")); 682 722 if (appVersion == NULL) 683 723 appVersion = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey); 684 if (appVersion != NULL) { 685 UInt32 intVersion = CFBundleGetVersionNumber(bundle); 686 CFStringGetCString(appVersion, tmpBuffer, STRBUF_LEN, CFStringGetSystemEncoding()); 687 printf("\tversion: %s", tmpBuffer); 688 if (intVersion != 0) printf(" [0x%lx = %lu]", intVersion, intVersion); 689 putchar('\n'); 690 } 724 if (appVersion != NULL) 725 intVersion = CFBundleGetVersionNumber(bundle); 691 726 CFRelease(bundle); 727 } 728 if (bundleID != NULL) { 729 CFStringGetCString(bundleID, tmpBuffer, STRBUF_LEN, CFStringGetSystemEncoding()); 730 printf("\tbundle ID: %s\n", tmpBuffer); 731 CFRelease(bundleID); 732 } 733 if (appVersion != NULL) { 734 CFStringGetCString(appVersion, tmpBuffer, STRBUF_LEN, CFStringGetSystemEncoding()); 735 printf("\tversion: %s", tmpBuffer); 736 if (intVersion != 0) printf(" [0x%lx = %lu]", intVersion, intVersion); 737 putchar('\n'); 738 CFRelease(appVersion); 692 739 } 693 740 }
Note:
See TracChangeset
for help on using the changeset viewer.