summaryrefslogtreecommitdiff
path: root/src/unix
diff options
context:
space:
mode:
authorJacques Germishuys <jacquesg@striata.com>2014-07-13 16:08:46 +0200
committerJacques Germishuys <jacquesg@striata.com>2014-08-05 20:52:00 +0200
commit662f90e6ecb6ad0576de89d0af8872eab678eb79 (patch)
tree8fc8210bc6e1679c848be8cfac6a7e0a128e2042 /src/unix
parentc7dd0a56bf81fa93327a1ec3c949a7d59a53f40d (diff)
downloadlibgit2-662f90e6ecb6ad0576de89d0af8872eab678eb79.tar.gz
Move p_realpath logic to realpath.c
Diffstat (limited to 'src/unix')
-rw-r--r--src/unix/posix.h8
-rw-r--r--src/unix/realpath.c15
2 files changed, 9 insertions, 14 deletions
diff --git a/src/unix/posix.h b/src/unix/posix.h
index 0c8732aff..c428384e4 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -26,18 +26,12 @@ typedef int GIT_SOCKET;
#define p_unlink(p) unlink(p)
#define p_mkdir(p,m) mkdir(p, m)
#define p_fsync(fd) fsync(fd)
+extern char *p_realpath(const char *, char *);
#define p_recv(s,b,l,f) recv(s,b,l,f)
#define p_send(s,b,l,f) send(s,b,l,f)
#define p_inet_pton(a, b, c) inet_pton(a, b, c)
-/* The OpenBSD realpath function behaves differently */
-#if !defined(__OpenBSD__)
-# define p_realpath(p, po) realpath(p, po)
-#else
-char *p_realpath(const char *, char *);
-#endif
-
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__)
#define p_mkstemp(p) mkstemp(p)
diff --git a/src/unix/realpath.c b/src/unix/realpath.c
index 15601bd22..2e49150c2 100644
--- a/src/unix/realpath.c
+++ b/src/unix/realpath.c
@@ -6,7 +6,7 @@
*/
#include <git2/common.h>
-#ifdef __OpenBSD__
+#ifndef GIT_WIN32
#include <limits.h>
#include <stdlib.h>
@@ -16,15 +16,16 @@
char *p_realpath(const char *pathname, char *resolved)
{
char *ret;
-
if ((ret = realpath(pathname, resolved)) == NULL)
return NULL;
- /* Figure out if the file exists */
- if (!access(ret, F_OK))
- return ret;
-
- return NULL;
+#ifdef __OpenBSD__
+ /* The OpenBSD realpath function behaves differently,
+ * figure out if the file exists */
+ if (access(ret, F_OK) < 0)
+ ret = NULL;
+#endif
+ return ret;
}
#endif