From 052741d3485780d8e029ada086e330fdd56ee7ac Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 23 Dec 2006 21:24:56 +0000 Subject: Add '-findiwads' command line hack so that the setup program can find out what games are installed. Provide a drop-down list in setup to allow the game type to be selected. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 803 --- setup/execute.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'setup/execute.c') diff --git a/setup/execute.c b/setup/execute.c index fb1ac722..8f60288b 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -26,6 +26,9 @@ #include #include +#include +#include + #include "textscreen.h" #include "configfile.h" @@ -96,9 +99,10 @@ void AddCmdLineParameter(execute_context_t *context, char *s, ...) fprintf(context->stream, "\n"); } -void ExecuteDoom(execute_context_t *context) +int ExecuteDoom(execute_context_t *context) { char *cmdline; + int result; fclose(context->stream); @@ -110,13 +114,22 @@ void ExecuteDoom(execute_context_t *context) sprintf(cmdline, "%s @%s", DOOM_BINARY, context->response_file); // Run the command - system(cmdline); + result = system(cmdline); free(cmdline); // Destroy context remove(context->response_file); free(context); + + if (WIFEXITED(result)) + { + return WEXITSTATUS(result); + } + else + { + return -1; + } } static void TestCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data)) @@ -174,3 +187,26 @@ txt_window_action_t *TestConfigAction(void) return test_action; } +// Invokes Doom to find which IWADs are installed. +// This is a cheap hack to avoid duplication of the complicated install +// path searching code inside Doom. + +int FindInstalledIWADs(void) +{ + execute_context_t *context; + int result; + + context = NewExecuteContext(); + AddCmdLineParameter(context, "-findiwads"); + result = ExecuteDoom(context); + + if (result < 0) + { + return 0; + } + else + { + return result; + } +} + -- cgit v1.2.3