summaryrefslogtreecommitdiff
path: root/gobject-introspection
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-30 16:11:09 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-30 16:11:09 +0200
commit2ca47ca089f2a50b81ace057c19db506aea361e5 (patch)
tree30179997792a9ddab2bc7db8a94b5e3b13c32426 /gobject-introspection
parent663d023a6bca8ccd04cd0e65ed8cc389379e5383 (diff)
downloadvala-2ca47ca089f2a50b81ace057c19db506aea361e5.tar.gz
Update gobject-introspection/grealpath.h from gobject-introspectio
This fixes the build on Windows and GNU/Hurd
Diffstat (limited to 'gobject-introspection')
-rw-r--r--gobject-introspection/grealpath.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/gobject-introspection/grealpath.h b/gobject-introspection/grealpath.h
index ca88190bc..f5af7cb58 100644
--- a/gobject-introspection/grealpath.h
+++ b/gobject-introspection/grealpath.h
@@ -1,6 +1,8 @@
#ifndef __G_REALPATH_H__
#define __G_REALPATH_H__
+#include <stdlib.h>
+
/**
* g_realpath:
*
@@ -10,11 +12,47 @@
static inline gchar*
g_realpath (const char *path)
{
+#ifndef _WIN32
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
char buffer [PATH_MAX];
if (realpath(path, buffer))
return g_strdup(buffer);
else
return NULL;
+#else
+ /* We don't want to include <windows.h> as it clashes horribly
+ * with token names from scannerparser.h. So just declare
+ * GetFullPathNameA() here.
+ */
+ extern __stdcall GetFullPathNameA(const char*, int, char*, char**);
+ char *buffer;
+ char dummy;
+ int rc, len;
+
+ rc = GetFullPathNameA(path, 1, &dummy, NULL);
+
+ if (rc == 0)
+ {
+ /* Weird failure, so just return the input path as such */
+ return g_strdup(path);
+ }
+
+ len = rc + 1;
+ buffer = g_malloc(len);
+
+ rc = GetFullPathNameA(path, len, buffer, NULL);
+
+ if (rc == 0 || rc > len)
+ {
+ /* Weird failure again */
+ g_free(buffer);
+ return g_strdup(path);
+ }
+
+ return buffer;
+#endif
}
#endif