From 4317282df03adfd885436893ecad82a71b109627 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 May 2004 09:32:31 +0000 Subject: [PATCH] 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 | 2 +- platform.h | 2 +- platform_unix.c | 6 +++--- ui_carbon.c | 15 ++++++++++++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/mojopatch.c b/mojopatch.c index e3cdd5c..d59b8df 100644 --- a/mojopatch.c +++ b/mojopatch.c @@ -1794,7 +1794,7 @@ static int process_patch_header(SerialArchive *ar, PatchHeader *h) if (!info_only()) { - if (!chdir_by_identifier(h->identifier, h->version)) + if (!chdir_by_identifier(h->product, h->identifier, h->version)) return(PATCHERROR); } /* if */ diff --git a/platform.h b/platform.h index 6d660d3..9473b0a 100644 --- a/platform.h +++ b/platform.h @@ -57,7 +57,7 @@ int get_file_size(const char *fname, long *fsize); 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); diff --git a/platform_unix.c b/platform_unix.c index 87ba7ac..eb580a3 100644 --- a/platform_unix.c +++ b/platform_unix.c @@ -375,9 +375,9 @@ int update_version(const char *ver) } /* 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 @@ int chdir_by_identifier(const char *str, const char *version) 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); diff --git a/ui_carbon.c b/ui_carbon.c index fe23969..7a93376 100644 --- a/ui_carbon.c +++ b/ui_carbon.c @@ -163,7 +163,7 @@ int ui_prompt_ny(const char *question) } /* 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 @@ int manually_locate_product(char *buf, size_t bufsize) 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");