From 70e02914682eb1959d8b385f76b5acf7486158cc Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Thu, 7 Apr 2011 18:34:11 -0400 Subject: Use GetTempDir instead of hardcoded path to c:\windows\tmp for unittests --- src/test/test.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/test.c b/src/test/test.c index f5b6a222a7..9b24a99b58 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -84,10 +84,16 @@ setup_directory(void) if (is_setup) return; #ifdef MS_WINDOWS - // XXXX - tor_snprintf(temp_dir, sizeof(temp_dir), - "c:\\windows\\temp\\tor_test_%d", (int)getpid()); - r = mkdir(temp_dir); + { + char buf[MAX_PATH]; + const char *tmp = buf; + /* If this fails, we're probably screwed anyway */ + if (!GetTempPath(sizeof(buf),buf)) + tmp = "c:\\windows\\temp"; + tor_snprintf(temp_dir, sizeof(temp_dir), + "%s\\tor_test_%d", tmp, (int)getpid()); + r = mkdir(temp_dir); + } #else tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d", (int) getpid()); r = mkdir(temp_dir, 0700); -- cgit v1.2.3-54-g00ecf