From e77e46ca48da31b73a2b8e44ab90e3237239cc23 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 May 2004 12:36:42 +0000 Subject: [PATCH] Always prompt the user to find their installation if product identifier isn't specified. --- platform_unix.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/platform_unix.c b/platform_unix.c index eb580a3..6b2a8bf 100644 --- a/platform_unix.c +++ b/platform_unix.c @@ -382,25 +382,36 @@ int chdir_by_identifier(const char *name, const char *str, const char *version) char buf[MAXPATHLEN]; Boolean b; OSStatus rc; - CFURLRef url = NULL; - CFStringRef id = CFStringCreateWithBytes(NULL, str, strlen(str), - kCFStringEncodingISOLatin1, 0); + int found = 0; - rc = LSFindApplicationForInfo(kLSUnknownCreator, id, NULL, NULL, &url); - CFRelease(id); - if (rc == noErr) + /* if an identifier is specified, ask LaunchServices to find product... */ + if ((str != NULL) && (*str)) { - b = CFURLGetFileSystemRepresentation(url, TRUE, buf, sizeof (buf)); - CFRelease(url); - if (!b) + CFURLRef url = NULL; + CFStringRef id = CFStringCreateWithBytes(NULL, str, strlen(str), + kCFStringEncodingISOLatin1, 0); + + rc = LSFindApplicationForInfo(kLSUnknownCreator, id, NULL, NULL, &url); + CFRelease(id); + if (rc == noErr) { - _fatal("Internal error."); - return(0); + b = CFURLGetFileSystemRepresentation(url, TRUE, buf, sizeof (buf)); + CFRelease(url); + if (!b) + { + _fatal("Internal error."); + return(0); + } /* if */ + found = 1; + } /* if */ + else + { + _log("Couldn't find product. Perhaps it isn't installed?"); } /* if */ } /* if */ - else + + if (!found) /* No identifier, or LaunchServices couldn't find it. */ { - _log("Couldn't find product. Perhaps it isn't installed?"); if (!manually_locate_product(name, buf, sizeof (buf))) { _fatal("We can't patch the product if we can't find it!");