changeset 715:179a7224dde1

Use g_build_filename().
author zas_
date Wed, 21 May 2008 00:32:57 +0000
parents 0f177c151368
children c534b8cecc1f
files src/rcfile.c src/search.c src/thumb.c
diffstat 3 files changed, 21 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/rcfile.c	Wed May 21 00:20:13 2008 +0000
+++ b/src/rcfile.c	Wed May 21 00:32:57 2008 +0000
@@ -299,7 +299,7 @@
 	gchar *rc_pathl;
 	gint i;
 
-	rc_path = g_strconcat(homedir(), "/", GQ_RC_DIR, "/", RC_FILE_NAME, NULL);
+	rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
 
 	rc_pathl = path_from_utf8(rc_path);
 	ssi = secure_open(rc_pathl);
@@ -609,7 +609,7 @@
 	for (i = 0; ExifUIList[i].key; i++)
 		ExifUIList[i].current = ExifUIList[i].default_value;
 
-	rc_path = g_strconcat(homedir(), "/", GQ_RC_DIR, "/", RC_FILE_NAME, NULL);
+	rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
 
 	rc_pathl = path_from_utf8(rc_path);
 	f = fopen(rc_pathl,"r");
--- a/src/search.c	Wed May 21 00:20:13 2008 +0000
+++ b/src/search.c	Wed May 21 00:32:57 2008 +0000
@@ -2159,7 +2159,7 @@
 		/* search metadata */
 
 		g_free(sd->search_path);
-		sd->search_path = g_strconcat(homedir(), "/", GQ_CACHE_RC_METADATA, NULL);
+		sd->search_path = g_build_filename(homedir(), GQ_CACHE_RC_METADATA, NULL);
 
 		search_start(sd);
 		}
--- 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)