summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-08-30 13:34:14 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-30 13:34:14 +0200
commitf978b748bb50beb0ccbebc3aa118ad289e4c9cba (patch)
tree701bde8e9edb4e4066a4ea54375668c3ae9c3d32 /src/fileops.c
parent3ef7d06302b97a24167cd1ceafeb08b871df1751 (diff)
downloadlibgit2-f978b748bb50beb0ccbebc3aa118ad289e4c9cba.tar.gz
compat: Move `mkstemp` to the POSIX compat layer
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/fileops.c b/src/fileops.c
index c7fddc623..d7413a138 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -55,18 +55,10 @@ int git_futils_mktmp(char *path_out, const char *filename)
strcpy(path_out, filename);
strcat(path_out, "_git2_XXXXXX");
-#if defined(_MSC_VER)
- /* FIXME: there may be race conditions when multi-threading
- * with the library */
- if (_mktemp_s(path_out, GIT_PATH_MAX) != 0)
- return git__throw(GIT_EOSERR, "Failed to make temporary file %s", path_out);
+ if ((fd = p_mkstemp(path_out)) < 0)
+ return git__throw(GIT_EOSERR, "Failed to create temporary file %s", path_out);
- fd = p_creat(path_out, 0744);
-#else
- fd = mkstemp(path_out);
-#endif
-
- return fd >= 0 ? fd : git__throw(GIT_EOSERR, "Failed to create temporary file %s", path_out);
+ return fd;
}
int git_futils_creat_withpath(const char *path, int mode)