diff options
Diffstat (limited to 'src/win32/posix.c')
| -rw-r--r-- | src/win32/posix.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/win32/posix.c b/src/win32/posix.c index 2d7b8390d..38e505e20 100644 --- a/src/win32/posix.c +++ b/src/win32/posix.c @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2009-2011 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ #include "posix.h" #include "path.h" #include <errno.h> @@ -138,13 +144,13 @@ int p_readlink(const char *link, char *target, size_t target_len) "'GetFinalPathNameByHandleA' is not available in this platform"); } - hFile = CreateFile(link, // file to open - GENERIC_READ, // open for reading - FILE_SHARE_READ, // share for reading - NULL, // default security - OPEN_EXISTING, // existing file only + hFile = CreateFile(link, // file to open + GENERIC_READ, // open for reading + FILE_SHARE_READ, // share for reading + NULL, // default security + OPEN_EXISTING, // existing file only FILE_FLAG_BACKUP_SEMANTICS, // normal file - NULL); // no attr. template + NULL); // no attr. template if (hFile == INVALID_HANDLE_VALUE) return GIT_EOSERR; @@ -157,7 +163,7 @@ int p_readlink(const char *link, char *target, size_t target_len) if (dwRet > 4) { /* Skip first 4 characters if they are "\\?\" */ - if (target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') { + if (target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') { char tmp[GIT_PATH_MAX]; unsigned int offset = 4; dwRet -= 4; @@ -183,7 +189,7 @@ int p_hide_directory__w32(const char *path) int error; error = SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN) != 0 ? - GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */ + GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */ if (error < GIT_SUCCESS) error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path); @@ -236,16 +242,13 @@ extern int p_creat(const char *path, int mode); int p_mkstemp(char *tmp_path) { - int r; - #if defined(_MSC_VER) - r = _mktemp_s(tmp_path, GIT_PATH_MAX); + if (_mktemp_s(tmp_path, GIT_PATH_MAX) != 0) + return GIT_EOSERR; #else - r = _mktemp(tmp_path); -#endif - - if (r != 0) + if (_mktemp(tmp_path) == NULL) return GIT_EOSERR; +#endif return p_creat(tmp_path, 0744); } |
