diff src/thumb.c @ 715:179a7224dde1

Use g_build_filename().
author zas_
date Wed, 21 May 2008 00:32:57 +0000
parents a3218946bd2d
children 9bd49e725ad3
line wrap: on
line diff
--- a/src/thumb.c	Wed May 21 00:20:13 2008 +0000
+++ b/src/thumb.c	Wed May 21 00:32:57 2008 +0000
@@ -51,9 +51,10 @@
 		{
 		gchar *cache_path;
 		gchar *pathl;
+		gchar *name = g_strconcat(filename_from_path(tl->path), GQ_CACHE_EXT_THUMB, NULL);
 
-		cache_path = g_strconcat(cache_dir, "/", filename_from_path(tl->path),
-					 GQ_CACHE_EXT_THUMB, NULL);
+		cache_path = g_build_filename(cache_dir, name, NULL);
+		g_free(name);
 
 		DEBUG_1("Saving thumb: %s", cache_path);
 
@@ -99,9 +100,10 @@
 		gchar *cache_path;
 		gchar *pathl;
 		FILE *f;
+		gchar *name = g_strconcat(filename_from_path(tl->path), GQ_CACHE_EXT_THUMB, NULL);
 
-		cache_path = g_strconcat(cache_dir, "/", filename_from_path(tl->path),
-					 GQ_CACHE_EXT_THUMB, NULL);
+		cache_path = g_build_filename(cache_dir, name, NULL);
+		g_free(name);
 
 		DEBUG_1("marking thumb failure: %s", cache_path);
 
@@ -609,18 +611,22 @@
 {
 	gint width, height;
 	gchar *thumb_name;
-	gchar *tmp_string;
-	gchar *last_slash;
+	gchar *path;
+	gchar *directory;
+	gchar *name;
 	guchar *packed_data;
 
-	tmp_string = path_from_utf8(thumb_filename);
-	last_slash = strrchr(tmp_string, '/');
-	if(!last_slash)	return NULL;
-	*last_slash++ = '\0';
+	path = path_from_utf8(thumb_filename);
+	directory = g_path_get_dirname(path);
+	name = g_path_get_basename(path);
+	
+	thumb_name = g_build_filename(directory, ".xvpics", name, NULL);
+	
+	g_free(name);
+	g_free(directory);
+	g_free(path);
 
-	thumb_name = g_strconcat(tmp_string, "/.xvpics/", last_slash, NULL);
 	packed_data = load_xv_thumbnail(thumb_name, &width, &height);
-	g_free(tmp_string);
 	g_free(thumb_name);
 
 	if(packed_data)