diff options
author | Simon Howard | 2006-12-23 21:24:56 +0000 |
---|---|---|
committer | Simon Howard | 2006-12-23 21:24:56 +0000 |
commit | 052741d3485780d8e029ada086e330fdd56ee7ac (patch) | |
tree | 439704265dd3cbbe140e5a08538e75129e0a359b /setup/execute.c | |
parent | 8630d0991eb32b3bedecb6655ac9935bd50391df (diff) | |
download | chocolate-doom-052741d3485780d8e029ada086e330fdd56ee7ac.tar.gz chocolate-doom-052741d3485780d8e029ada086e330fdd56ee7ac.tar.bz2 chocolate-doom-052741d3485780d8e029ada086e330fdd56ee7ac.zip |
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
Diffstat (limited to 'setup/execute.c')
-rw-r--r-- | setup/execute.c | 40 |
1 files changed, 38 insertions, 2 deletions
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 <stdlib.h> #include <string.h> +#include <sys/types.h> +#include <sys/wait.h> + #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; + } +} + |