summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2011-05-12 10:12:54 +0200
committerChristian Kellner <gicmo@gnome.org>2011-05-12 11:21:47 +0200
commit66bc0189d836130768df41900f3cf29723bbd870 (patch)
tree306b7e2f0d2193eee99aa9ae5d601dce4f0bceb0 /common
parentbc2d4117fe18e1750c13e38e09a0c04d3a60de67 (diff)
New function to re-root a given path with a mount_prefix
g_mount_info_apply_prefix will take an given path and prepend the mount_prefix of the given mount_info, if there is any. It will free the old string in this case. Otherwise it is a NOOP.
Diffstat (limited to 'common')
-rw-r--r--common/gmounttracker.c20
-rw-r--r--common/gmounttracker.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/common/gmounttracker.c b/common/gmounttracker.c
index 9c7af7b4..519cd475 100644
--- a/common/gmounttracker.c
+++ b/common/gmounttracker.c
@@ -153,6 +153,26 @@ g_mount_info_resolve_path (GMountInfo *info,
return new_path;
}
+void
+g_mount_info_apply_prefix (GMountInfo *info,
+ char **path)
+{
+ GMountSpec *spec;
+
+ spec = info->mount_spec;
+
+ if (spec->mount_prefix != NULL &&
+ spec->mount_prefix[0] != 0)
+ {
+ char *path_with_prefix;
+ path_with_prefix = g_build_path ("/", spec->mount_prefix,
+ *path, NULL);
+ g_free (*path);
+ *path = path_with_prefix;
+ }
+
+}
+
GMountInfo *
g_mount_info_from_dbus (DBusMessageIter *iter)
{
diff --git a/common/gmounttracker.h b/common/gmounttracker.h
index 4892baaf..47236637 100644
--- a/common/gmounttracker.h
+++ b/common/gmounttracker.h
@@ -73,6 +73,8 @@ GMountInfo *g_mount_info_dup (GMountInfo *info);
void g_mount_info_unref (GMountInfo *info);
const char *g_mount_info_resolve_path (GMountInfo *info,
const char *path);
+void g_mount_info_apply_prefix (GMountInfo *info,
+ char **path);
GMountInfo * g_mount_info_from_dbus (DBusMessageIter *iter);