changeset 889:7bde71a1ea91

Improve path support.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 09 Nov 2012 06:20:12 +0200
parents 1779967c472a
children 62d164e3f0ce
files src/xs_support.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_support.c	Fri Nov 09 06:17:56 2012 +0200
+++ b/src/xs_support.c	Fri Nov 09 06:20:12 2012 +0200
@@ -144,9 +144,15 @@
 gboolean xs_fload_buffer_path(const gchar *ppath, const gchar *pfilename,
     guint8 **pbuf, size_t *bufSize, const size_t maxSize, gboolean failMaxSize)
 {
-    gchar *filename = g_strdup_printf("%s%s", ppath != NULL ? ppath : "", pfilename);
+    gchar *filename, *pseparator;
     gboolean res;
 
+    if (pfilename == NULL)
+        return FALSE;
+
+    pseparator = ppath != NULL ? ((ppath[strlen(ppath)] != '/') ? "/" : "") : "";
+    filename = g_strdup_printf("%s%s%s", ppath, pseparator, pfilename);
+
     if (filename == NULL)
         return FALSE;
 
@@ -156,6 +162,7 @@
     return res;
 }
 
+
 /* Copy a given string over in *result.
  */
 gint xs_pstrcpy(gchar **result, const gchar *str)