diff options
author | Ian Lynagh <igloo@earth.li> | 2009-10-27 20:25:03 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2009-10-27 20:25:03 +0000 |
commit | 6cf8982ac30be6836a0cdd8be5a6ac1a1a144213 (patch) | |
tree | 604f63fabadfd1d2bd2b480f5f1a7ed2211778b8 /driver/utils/getLocation.c | |
parent | 48196c3c2a365ce085d0b0567cbd4ea047af59df (diff) | |
download | haskell-6cf8982ac30be6836a0cdd8be5a6ac1a1a144213.tar.gz |
Wrap gcc on Windows, to provide the -B flags
Diffstat (limited to 'driver/utils/getLocation.c')
-rw-r--r-- | driver/utils/getLocation.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/driver/utils/getLocation.c b/driver/utils/getLocation.c new file mode 100644 index 0000000000..fcbe1b940c --- /dev/null +++ b/driver/utils/getLocation.c @@ -0,0 +1,40 @@ + +#include "getLocation.h" +#include <stdio.h> +#include <windows.h> + +static void die(char *msg) { + fprintf(stderr, "%s", msg); + exit(1); +} + +char *getExecutable(void) { + char *p; + int i; + int r; + + i = 2048; /* plenty, PATH_MAX is 512 under Win32 */ + p = malloc(i); + if (p == NULL) { + die("Malloc failed\n"); + } + r = GetModuleFileNameA(NULL, p, i); + if (r == 0) { + die("getModuleFileName failed\n"); + } + return p; +} + +char *getExecutablePath(void) { + char *p; + char *f; + + p = getExecutable(); + f = strrchr(p, '\\'); + if (f == NULL) { + die("No '\\' in executable location\n"); + } + f[0] = '\0'; + return p; +} + |