summaryrefslogtreecommitdiff
path: root/gsystem-file-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gsystem-file-utils.c')
-rw-r--r--gsystem-file-utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index 5fb0252..bc34b7c 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -33,6 +33,7 @@
#include <glib/gstdio.h>
#include <gio/gunixinputstream.h>
#include <glib-unix.h>
+#include <limits.h>
static int
close_nointr (int fd)
@@ -967,3 +968,25 @@ gs_file_get_relpath (GFile *one,
return g_string_free (path, FALSE);
}
+
+/**
+ * gs_file_realpath:
+ * @file: A #GFile
+ *
+ * Return a #GFile that contains the same path with symlinks
+ * followed. That is, it's a #GFile whose path is the result
+ * of calling realpath() on @file.
+ *
+ * Returns: (transfer full): A new #GFile
+ */
+GFile *
+gs_file_realpath (GFile *file)
+{
+ gchar *path;
+ gchar path_real[PATH_MAX];
+
+ path = g_file_get_path (file);
+ realpath ((const char *) path, path_real);
+ g_free (path);
+ return g_file_new_for_path (path_real);
+}