summaryrefslogtreecommitdiff
path: root/src/win32/posix.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-07-04 21:33:26 +0200
committerVicent Marti <tanoku@gmail.com>2011-07-04 21:33:26 +0200
commitd3789825d3823bdbbebe278172345243618ca541 (patch)
tree6d7a528c92076ca443e2ae226134dd1f40a642fa /src/win32/posix.c
parent843d01d27f4372de24b3255146cf0fda70b850c1 (diff)
downloadlibgit2-fileops.tar.gz
fileops: Fix stat() on directories for W32fileops
Diffstat (limited to 'src/win32/posix.c')
-rw-r--r--src/win32/posix.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/win32/posix.c b/src/win32/posix.c
index 610a4166c..dfa4e1a2c 100644
--- a/src/win32/posix.c
+++ b/src/win32/posix.c
@@ -190,13 +190,22 @@ int p_hide_directory__w32(const char *path)
return error;
}
-int p_realpath(const char *orig_path, char *buffer)
+char *p_realpath(const char *orig_path, char *buffer)
{
- int ret = GetFullPathName(orig_path, GIT_PATH_MAX, buffer, NULL);
- if (!ret || ret > GIT_PATH_MAX)
- return GIT_EOSERR;
+ int ret, alloc = 0;
+
+ if (buffer == NULL) {
+ buffer = (char *)git__malloc(GIT_PATH_MAX);
+ alloc = 1;
+ }
+
+ ret = GetFullPathName(orig_path, GIT_PATH_MAX, buffer, NULL);
+ if (!ret || ret > GIT_PATH_MAX) {
+ if (alloc) free(buffer);
+ return NULL;
+ }
git_path_mkposix(buffer);
- return GIT_SUCCESS;
+ return buffer;
}