summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/posix.c19
-rw-r--r--src/win32/posix.h2
2 files changed, 15 insertions, 6 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;
}
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 3b5bff806..90571ae1d 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -21,6 +21,6 @@ extern int p_unlink(const char *path);
extern int p_lstat(const char *file_name, struct stat *buf);
extern int p_readlink(const char *link, char *target, size_t target_len);
extern int p_hide_directory__w32(const char *path);
-extern int p_realpath(const char *orig_path, char *buffer);
+extern char *p_realpath(const char *orig_path, char *buffer);
#endif