changeset 716:c534b8cecc1f

thumb_std_cache_path(): use g_build_filename() and simplify.
author zas_
date Wed, 21 May 2008 00:39:16 +0000
parents 179a7224dde1
children aae956e84de4
files src/thumb_standard.c
diffstat 1 files changed, 12 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/thumb_standard.c	Wed May 21 00:32:57 2008 +0000
+++ b/src/thumb_standard.c	Wed May 21 00:39:16 2008 +0000
@@ -135,34 +135,32 @@
 				   const gchar *cache_subfolder)
 {
 	gchar *result = NULL;
-	gchar *cache_base;
 	gchar *md5_text;
 	guchar digest[16];
+	gchar *name;
 
 	if (!path || !uri || !cache_subfolder) return NULL;
 
+	md5_get_digest((guchar *)uri, strlen(uri), digest);
+	md5_text = md5_digest_to_text(digest);
+
+	if (!md5_text) return NULL;
+
+	name = g_strconcat(md5_text, THUMB_NAME_EXTENSION, NULL);
+
 	if (local)
 		{
-		gchar *base;
+		gchar *base = remove_level_from_path(path);
 
-		base = remove_level_from_path(path);
-		cache_base = g_strconcat(base, "/", THUMB_FOLDER_LOCAL, "/", cache_subfolder, NULL);
+		result = g_build_filename(base, THUMB_FOLDER_LOCAL, cache_subfolder, name, NULL);
 		g_free(base);
 		}
 	else
 		{
-		cache_base = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", cache_subfolder, NULL);
+		result = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, cache_subfolder, name, NULL);
 		}
 
-	md5_get_digest((guchar *)uri, strlen(uri), digest);
-	md5_text = md5_digest_to_text(digest);
-
-	if (cache_base && md5_text)
-		{
-		result = g_strconcat(cache_base, "/", md5_text, THUMB_NAME_EXTENSION, NULL);
-		}
-
-	g_free(cache_base);
+	g_free(name);
 	g_free(md5_text);
 
 	return result;