summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-09-04 15:03:12 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-09-07 17:35:04 +0100
commit416486d706a4d717ad5670abca61e333471bfbdc (patch)
treefda00bc3ed93f0c00ef93adefcb003e0c5dcbd4d
parent947aaa3c91f7f286d37f803286d77070f0cc6fb2 (diff)
downloadtelepathy-mission-control-416486d706a4d717ad5670abca61e333471bfbdc.tar.gz
mcd_ensure_directory: add
I keep calling g_mkdir_with_parents() and expecting it to return a boolean (it doesn't, it returns 0 or -1), so it seems worth wrapping it in something more sensible. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=35896 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--src/mcd-misc.c17
-rw-r--r--src/mcd-misc.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mcd-misc.c b/src/mcd-misc.c
index 294d2a78..c0cc4e13 100644
--- a/src/mcd-misc.c
+++ b/src/mcd-misc.c
@@ -176,6 +176,23 @@ _mcd_object_ready (gpointer object, GQuark quark, const GError *error)
g_object_unref (object);
}
+gboolean
+mcd_ensure_directory (const gchar *dir,
+ GError **error)
+{
+ DEBUG ("%s", dir);
+
+ if (g_mkdir_with_parents (dir, 0700) != 0)
+ {
+ g_set_error (error, TP_ERROR, TP_ERROR_NOT_AVAILABLE,
+ "Unable to create directory '%s': %s",
+ dir, g_strerror (errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
int
_mcd_chmod_private (const gchar *filename)
{
diff --git a/src/mcd-misc.h b/src/mcd-misc.h
index e69ee728..741a1092 100644
--- a/src/mcd-misc.h
+++ b/src/mcd-misc.h
@@ -51,6 +51,8 @@ void _mcd_object_ready (gpointer object, GQuark quark, const GError *error);
G_GNUC_INTERNAL
void _mcd_ext_register_dbus_glib_marshallers (void);
+gboolean mcd_ensure_directory (const gchar *dir, GError **error);
+
G_GNUC_INTERNAL int _mcd_chmod_private (const gchar *filename);
G_END_DECLS