comparison src/xs_support.c @ 889:7bde71a1ea91

Improve path support.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 09 Nov 2012 06:20:12 +0200
parents 1779967c472a
children c835aa129e3b
comparison
equal deleted inserted replaced
888:1779967c472a 889:7bde71a1ea91
142 142
143 143
144 gboolean xs_fload_buffer_path(const gchar *ppath, const gchar *pfilename, 144 gboolean xs_fload_buffer_path(const gchar *ppath, const gchar *pfilename,
145 guint8 **pbuf, size_t *bufSize, const size_t maxSize, gboolean failMaxSize) 145 guint8 **pbuf, size_t *bufSize, const size_t maxSize, gboolean failMaxSize)
146 { 146 {
147 gchar *filename = g_strdup_printf("%s%s", ppath != NULL ? ppath : "", pfilename); 147 gchar *filename, *pseparator;
148 gboolean res; 148 gboolean res;
149
150 if (pfilename == NULL)
151 return FALSE;
152
153 pseparator = ppath != NULL ? ((ppath[strlen(ppath)] != '/') ? "/" : "") : "";
154 filename = g_strdup_printf("%s%s%s", ppath, pseparator, pfilename);
149 155
150 if (filename == NULL) 156 if (filename == NULL)
151 return FALSE; 157 return FALSE;
152 158
153 res = xs_fload_buffer(filename, pbuf, bufSize, maxSize, failMaxSize); 159 res = xs_fload_buffer(filename, pbuf, bufSize, maxSize, failMaxSize);
154 160
155 g_free(filename); 161 g_free(filename);
156 return res; 162 return res;
157 } 163 }
164
158 165
159 /* Copy a given string over in *result. 166 /* Copy a given string over in *result.
160 */ 167 */
161 gint xs_pstrcpy(gchar **result, const gchar *str) 168 gint xs_pstrcpy(gchar **result, const gchar *str)
162 { 169 {