gtk+-3.0: Fix gtk_widget_adjust_size_* bindings
[vala-lang.git] / gobject-introspection / grealpath.h
blobf5af7cb58c038293df3c46f1d3e643d44346c670
1 #ifndef __G_REALPATH_H__
2 #define __G_REALPATH_H__
4 #include <stdlib.h>
6 /**
7 * g_realpath:
9 * this should be a) filled in for win32 and b) put in glib...
12 static inline gchar*
13 g_realpath (const char *path)
15 #ifndef _WIN32
16 #ifndef PATH_MAX
17 #define PATH_MAX 4096
18 #endif
19 char buffer [PATH_MAX];
20 if (realpath(path, buffer))
21 return g_strdup(buffer);
22 else
23 return NULL;
24 #else
25 /* We don't want to include <windows.h> as it clashes horribly
26 * with token names from scannerparser.h. So just declare
27 * GetFullPathNameA() here.
29 extern __stdcall GetFullPathNameA(const char*, int, char*, char**);
30 char *buffer;
31 char dummy;
32 int rc, len;
34 rc = GetFullPathNameA(path, 1, &dummy, NULL);
36 if (rc == 0)
38 /* Weird failure, so just return the input path as such */
39 return g_strdup(path);
42 len = rc + 1;
43 buffer = g_malloc(len);
45 rc = GetFullPathNameA(path, len, buffer, NULL);
47 if (rc == 0 || rc > len)
49 /* Weird failure again */
50 g_free(buffer);
51 return g_strdup(path);
54 return buffer;
55 #endif
58 #endif