changeset 32092:c5d6befd0765

make a get_absolute_path function.
author tdrhq@soc.pidgin.im
date Mon, 10 Aug 2009 10:34:52 +0000
parents 9ed5d83f52fe
children a6d6b0867cd3
files pidgin/plugins/adiumthemes/webkit.c
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/adiumthemes/webkit.c	Mon Aug 10 10:30:31 2009 +0000
+++ b/pidgin/plugins/adiumthemes/webkit.c	Mon Aug 10 10:34:52 2009 +0000
@@ -83,6 +83,17 @@
 static char  *cur_style_dir = NULL;
 static void  *handle = NULL;
 
+static inline char* get_absolute_path (const char *path)
+{
+	if (g_path_is_absolute (path)) return g_strdup (path);
+	else {
+		char* cwd = g_get_current_dir (), *ret;
+		ret = g_build_filename (cwd, path, NULL);
+		g_free (cwd);
+		return ret;
+	}
+}
+
 static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
 {
 	PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
@@ -623,13 +634,7 @@
 	char *user_dir, *user_style_dir, *global_style_dir;
 	GList *list1, *list2;
 
-	user_dir = g_strdup (purple_user_dir ());
-	if (!g_path_is_absolute (user_dir)) {
-		char* cur = g_get_current_dir ();
-		g_free (user_dir);
-		user_dir = g_build_filename (cur, purple_user_dir(), NULL);
-		g_free (cur);
-	}
+	user_dir = get_absolute_path (purple_user_dir ());
 
 	user_style_dir = g_build_filename (user_dir, "styles", NULL);
 	global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL);