From: Johannes Sixt Date: Sun, 22 Jun 2008 09:35:21 +0000 (+0200) Subject: Windows: TMP and TEMP environment variables specify a temporary directory. X-Git-Tag: v1.6.0-rc0~159^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6fd6aec44fe79dff61fd37a5fec2456c5458b574;p=git.git Windows: TMP and TEMP environment variables specify a temporary directory. Signed-off-by: Johannes Sixt --- diff --git a/compat/mingw.c b/compat/mingw.c index 28d32969b..3a05fe7da 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -366,6 +366,19 @@ char *mingw_getcwd(char *pointer, int len) return ret; } +#undef getenv +char *mingw_getenv(const char *name) +{ + char *result = getenv(name); + if (!result && !strcmp(name, "TMPDIR")) { + /* on Windows it is TMP and TEMP */ + result = getenv("TMP"); + if (!result) + result = getenv("TEMP"); + } + return result; +} + /* * See http://msdn2.microsoft.com/en-us/library/17w5ykft(vs.71).aspx * (Parsing C++ Command-Line Arguments) diff --git a/compat/mingw.h b/compat/mingw.h index 624b32d1f..a87cc9679 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -145,6 +145,9 @@ int mingw_open (const char *filename, int oflags, ...); char *mingw_getcwd(char *pointer, int len); #define getcwd mingw_getcwd +char *mingw_getenv(const char *name); +#define getenv mingw_getenv + struct hostent *mingw_gethostbyname(const char *host); #define gethostbyname mingw_gethostbyname