@kugel- requested changes on this pull request.
if (size > PATH_MAX)
+ return NULL; + else + return resolved_path; + } + else + { + size = GetFullPathNameA(pathname, 0, NULL, NULL); + resolved_path = g_new0(char, size); + GetFullPathNameA(pathname, size, resolved_path, NULL); + return resolved_path; + } +} +#endif + + /** * Get a link-dereferenced, absolute version of a file name. * * This is similar to the POSIX `realpath` function when passed a * @c NULL argument.
I think we can be clear here and say that this *is* realpath, except on Windows.
@@ -2436,7 +2463,12 @@ void utils_start_new_geany_instance(const gchar *doc_path)
GEANY_API_SYMBOL gchar *utils_get_real_path(const gchar *file_name) { - return tm_get_real_path(file_name); + gchar *path = NULL; + + if (file_name) + path = realpath(file_name, NULL);
We don't really need to implement a wrapper for `realpath()` if the only caller always passes NULL.
I suggest this ``` gchar *path = NULL;
if (file_name) { #if defined(G_OS_WIN32) && !defined(HAVE_REALPATH) gsize size = GetFullPathNameA(pathname, 0, NULL, NULL); path = g_new0(char, size); GetFullPathNameA(pathname, size, path, NULL); #else path = realpath(file_name, NULL); #endif } return path; ```