telepathy-mission-control: mcd_ensure_directory: add
Simon McVittie
smcv at kemper.freedesktop.org
Thu Sep 20 08:15:56 PDT 2012
Module: telepathy-mission-control
Branch: master
Commit: 416486d706a4d717ad5670abca61e333471bfbdc
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=416486d706a4d717ad5670abca61e333471bfbdc
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Tue Sep 4 15:03:12 2012 +0100
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 at collabora.co.uk>
---
src/mcd-misc.c | 17 +++++++++++++++++
src/mcd-misc.h | 2 ++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/mcd-misc.c b/src/mcd-misc.c
index 294d2a7..c0cc4e1 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 e69ee72..741a109 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
More information about the telepathy-commits
mailing list