Implment p_access and use it in git_fileutils_exists Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/src/fileops.c b/src/fileops.c
index bfd63f5..203cce0 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -127,7 +127,7 @@ int git_futils_isfile(const char *path)
int git_futils_exists(const char *path)
{
assert(path);
- return access(path, F_OK);
+ return p_access(path, F_OK);
}
git_off_t git_futils_filesize(git_file fd)
diff --git a/src/posix.h b/src/posix.h
index d656e8e..497e21f 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -52,6 +52,7 @@ extern char* p_getenv(const char* name);
#define p_chdir(p) chdir(p)
#define p_rmdir(p) rmdir(p)
#define p_chmod(p,m) chmod(p, m)
+#define p_access(p,m) access(p,m)
#endif
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 4c45fd3..d82506a 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -43,6 +43,6 @@ extern int p_stat(const char* path, struct stat* buf);
extern int p_chdir(const char* path);
extern int p_chmod(const char* path, int mode);
extern int p_rmdir(const char* path);
-
+extern int p_access(const char* path, int mode);
#endif
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 85a04bc..228897d 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -401,3 +401,14 @@ int p_setenv(const char* name, const char* value, int overwrite)
return (SetEnvironmentVariableA(name, value) == 0 ? GIT_EOSERR : GIT_SUCCESS);
}
+
+int p_access(const char* path, int mode)
+{
+ wchar_t *buf = conv_utf8_to_utf16(path);
+ int ret;
+
+ ret = _waccess(buf, mode);
+ free(buf);
+
+ return ret;
+}