/* For Native Client, the above is not true. Since there is no getcwd we fill */
/* in the file being passed in relative to '.' and don't resolve it */
+
+/* There are a couple of tests for this method in mono/test/mono-path.cs */
gchar *
mono_path_canonicalize (const char *path)
{
if (g_path_is_absolute (path)) {
abspath = g_strdup (path);
} else {
-#ifdef __native_client__
- gchar *tmpdir = ".";
- abspath = g_build_filename (tmpdir, path, NULL);
-#else
gchar *tmpdir = g_get_current_dir ();
abspath = g_build_filename (tmpdir, path, NULL);
g_free (tmpdir);
-#endif
}
#ifdef HOST_WIN32
#endif
if (dest != lastpos) strcpy (dest, lastpos);
- return g_strreverse (abspath);
+
+ g_strreverse (abspath);
+
+ /* We strip away all trailing dir separators. This is not correct for the root directory,
+ * since we'll return an empty string, so re-append a dir separator if there is none in the
+ * result */
+ if (strchr (abspath, G_DIR_SEPARATOR) == NULL) {
+ int len = strlen (abspath);
+ abspath = (gchar *) g_realloc (abspath, len + 2);
+ abspath [len] = G_DIR_SEPARATOR;
+ abspath [len+1] = 0;
+ }
+
+ return abspath;
}
/*