When trying to locate a product, pass in proper name, so UI can refer to it.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 27 May 2004 09:32:31 +0000
changeset 19 f556da1872f4
parent 18 ca4755d5f27a
child 20 60ed4c1a9d2b
When trying to locate a product, pass in proper name, so UI can refer to it. (i.e. - I can't find "Neverwinter Nights Dedicated Server" instead of "I can't find the product"). This is twice as useful for patchfiles with multiple products.
mojopatch.c
platform.h
platform_unix.c
ui_carbon.c
--- a/mojopatch.c	Thu May 27 09:21:52 2004 +0000
+++ b/mojopatch.c	Thu May 27 09:32:31 2004 +0000
@@ -1794,7 +1794,7 @@
 
     if (!info_only())
     {
-        if (!chdir_by_identifier(h->identifier, h->version))
+        if (!chdir_by_identifier(h->product, h->identifier, h->version))
             return(PATCHERROR);
     } /* if */
 
--- a/platform.h	Thu May 27 09:21:52 2004 +0000
+++ b/platform.h	Thu May 27 09:32:31 2004 +0000
@@ -57,7 +57,7 @@
 char *get_current_dir(void);
 char *get_realpath(const char *path);
 int spawn_xdelta(const char *cmdline);
-int chdir_by_identifier(const char *id, const char *version);
+int chdir_by_identifier(const char *name, const char *str, const char *ver);
 int update_version(const char *ver);
 int calc_tmp_filenames(char **tmp1, char **tmp2);
 int show_and_install_readme(const char *fname, const char *text);
--- a/platform_unix.c	Thu May 27 09:21:52 2004 +0000
+++ b/platform_unix.c	Thu May 27 09:32:31 2004 +0000
@@ -375,9 +375,9 @@
 } /* update_version */
 
 
-int manually_locate_product(char *buf, size_t bufsize);
+int manually_locate_product(const char *name, char *buf, size_t bufsize);
 
-int chdir_by_identifier(const char *str, const char *version)
+int chdir_by_identifier(const char *name, const char *str, const char *version)
 {
     char buf[MAXPATHLEN];
     Boolean b;
@@ -401,7 +401,7 @@
     else
     {
         _log("Couldn't find product. Perhaps it isn't installed?");
-        if (!manually_locate_product(buf, sizeof (buf)))
+        if (!manually_locate_product(name, buf, sizeof (buf)))
         {
             _fatal("We can't patch the product if we can't find it!");
             return(0);
--- a/ui_carbon.c	Thu May 27 09:21:52 2004 +0000
+++ b/ui_carbon.c	Thu May 27 09:32:31 2004 +0000
@@ -163,7 +163,7 @@
 } /* ui_prompt_ny */
 
 
-int manually_locate_product(char *buf, size_t bufsize)
+int manually_locate_product(const char *name, char *buf, size_t bufsize)
 {
     NavDialogCreationOptions dlgopt;
     NavDialogRef dlg;
@@ -175,9 +175,18 @@
     OSStatus rc;
     int retval = 0;
     int yn;
+    const char *promptfmt = "We can't find your \"%s\" installation."
+                            " Would you like to show us where it is?";
+    char *promptstr = alloca(strlen(name) + strlen(promptfmt) + 1);
 
-    yn = ui_prompt_yn("We can't find your installation."
-                      " Would you like to show us where it is?");
+    if (promptstr == NULL)
+    {
+        _fatal("Out of memory.");
+        return(0);
+    } /* if */
+    sprintf(promptstr, promptfmt, name);
+
+    yn = ui_prompt_yn(promptstr);
     if (!yn)
     {
         _log("User chose not to manually locate installation");