commit 66bc0189d836130768df41900f3cf29723bbd870 Author: Christian Kellner Date: Thu May 12 10:12:54 2011 +0200 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. diff --git a/common/gmounttracker.c b/common/gmounttracker.c index 9c7af7b..519cd47 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 4892baa..4723663 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);