summaryrefslogtreecommitdiff
path: root/tests-clay/clay_main.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-10-01 13:25:24 +0200
committerVicent Marti <tanoku@gmail.com>2011-10-01 13:25:24 +0200
commitdfd0abda4de43b58b0c035b6bdb5ced236cfa081 (patch)
treea22975a739c769a3e1bb0b81f428b827f8c64b26 /tests-clay/clay_main.c
parent10063aeb41bdbdf8f887cbb93c8cc456b809aafb (diff)
downloadlibgit2-dfd0abda4de43b58b0c035b6bdb5ced236cfa081.tar.gz
clay: Fix compilation under MSVC
Diffstat (limited to 'tests-clay/clay_main.c')
-rw-r--r--tests-clay/clay_main.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests-clay/clay_main.c b/tests-clay/clay_main.c
index 602ca1c63..9cbabb940 100644
--- a/tests-clay/clay_main.c
+++ b/tests-clay/clay_main.c
@@ -16,7 +16,6 @@
# include <io.h>
# include <shellapi.h>
# include <direct.h>
-# pragma comment(lib, "shell32")
# define _MAIN_CC __cdecl
@@ -27,9 +26,11 @@
# define strdup(str) _strdup(str)
# ifndef __MINGW32__
+# pragma comment(lib, "shell32")
# define strncpy(to, from, to_size) strncpy_s(to, to_size, from, _TRUNCATE)
# define W_OK 02
# define S_ISDIR(x) ((x & _S_IFDIR) != 0)
+# define mktemp_s(path, len) _mktemp_s(path, len)
# endif
typedef struct _stat STAT_T;
#else
@@ -368,15 +369,12 @@ is_valid_tmp_path(const char *path)
static int
find_tmp_path(char *buffer, size_t length)
{
+#ifndef _WIN32
static const size_t var_count = 4;
static const char *env_vars[] = {
"TMPDIR", "TMP", "TEMP", "USERPROFILE"
};
-#ifdef _WIN32
- if (GetTempPath((DWORD)length, buffer))
- return 0;
-#else
size_t i;
for (i = 0; i < var_count; ++i) {
@@ -395,6 +393,10 @@ find_tmp_path(char *buffer, size_t length)
strncpy(buffer, "/tmp", length);
return 0;
}
+
+#else
+ if (GetTempPath((DWORD)length, buffer))
+ return 0;
#endif
/* This system doesn't like us, try to use the current directory */
@@ -444,8 +446,8 @@ static int build_sandbox_path(void)
strncpy(_clay_path + len, path_tail, sizeof(_clay_path) - len);
-#ifdef _MSC_VER
- if (_mktemp_s(_clay_path, sizeof(_clay_path)) != 0)
+#ifdef _WIN32
+ if (mktemp_s(_clay_path, sizeof(_clay_path)) != 0)
return -1;
if (mkdir(_clay_path, 0700) != 0)