From 20006966ab737e3da0ed107cf0dfb1e349be205d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Tue, 23 Sep 2014 22:22:28 +0200 Subject: [PATCH] winegcc: Respect TMPDIR environment variable. --- tools/winegcc/winegcc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 72e2e69d30b..a2f09d21e51 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -268,9 +268,12 @@ static char* get_temp_file(const char* prefix, const char* suffix) fd = mkstemps( tmp, strlen(suffix) ); if (fd == -1) { - /* could not create it in current directory, try in /tmp */ + /* could not create it in current directory, try in TMPDIR */ + const char* tmpdir; + free(tmp); - tmp = strmake("/tmp/%s-XXXXXX%s", prefix, suffix); + if (!(tmpdir = getenv("TMPDIR"))) tmpdir = "/tmp"; + tmp = strmake("%s/%s-XXXXXX%s", tmpdir, prefix, suffix); fd = mkstemps( tmp, strlen(suffix) ); if (fd == -1) error( "could not create temp file\n" ); }