Skip to content

Instantly share code, notes, and snippets.

@scottjg
Created May 5, 2012 20:06
Show Gist options
  • Save scottjg/2605249 to your computer and use it in GitHub Desktop.
Save scottjg/2605249 to your computer and use it in GitHub Desktop.
text version of my fix for libgit2 compilation on mingw32
--- clar.c.orig 2012-05-05 02:01:43 -0700
+++ clar.c 2012-05-05 02:10:45 -0700
@@ -29,7 +29,6 @@
# 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
--- clar_sandbox.c.orig 2012-05-05 02:08:35 -0700
+++ clar_sandbox.c 2012-05-05 02:13:33 -0700
@@ -94,8 +94,14 @@
strncpy(_clar_path + len, path_tail, sizeof(_clar_path) - len);
-#ifdef _WIN32
- if (mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
+#if defined(__MINGW32__)
+ if (_mktemp(_clar_path) == NULL)
+ return -1;
+
+ if (mkdir(_clar_path, 0700) != 0)
+ return -1;
+#elif defined(_WIN32)
+ if (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
return -1;
if (mkdir(_clar_path, 0700) != 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment