[Github-comments] [geany/geany] Remove deprecated symbol: tm_get_real_path (PR #3024)

Thomas Martitz notifications at xxxxx
Fri Feb 18 21:43:22 UTC 2022


@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;
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3024#pullrequestreview-887782202
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3024/review/887782202 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20220218/c057f2ad/attachment-0001.htm>


More information about the Github-comments mailing list