From d3789825d3823bdbbebe278172345243618ca541 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Mon, 4 Jul 2011 21:33:26 +0200 Subject: fileops: Fix stat() on directories for W32 --- src/win32/posix.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/win32/posix.c') 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; } -- cgit v1.2.1