Mercurial > audlegacy
comparison src/audacious/tuple.c @ 3833:f4f30254833b
better fix
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 21 Oct 2007 08:46:58 -0500 |
parents | 194c6d2c25bc |
children | d087573f54fd |
comparison
equal
deleted
inserted
replaced
3832:194c6d2c25bc | 3833:f4f30254833b |
---|---|
143 | 143 |
144 TUPLE_UNLOCK_WRITE(); | 144 TUPLE_UNLOCK_WRITE(); |
145 return tuple; | 145 return tuple; |
146 } | 146 } |
147 | 147 |
148 static gboolean | |
149 _tuple_associate_raw_string(Tuple *tuple, const gint nfield, const gchar *field, const gchar *string) | |
150 { | |
151 TupleValue *value; | |
152 | |
153 TUPLE_LOCK_WRITE(); | |
154 if ((value = tuple_associate_data(tuple, nfield, field, TUPLE_STRING)) == NULL) | |
155 return FALSE; | |
156 | |
157 if (string == NULL) | |
158 value->value.string = NULL; | |
159 else | |
160 value->value.string = g_strdup(string); | |
161 | |
162 TUPLE_UNLOCK_WRITE(); | |
163 return TRUE; | |
164 } | |
165 | |
148 Tuple * | 166 Tuple * |
149 tuple_new_from_filename(const gchar *filename) | 167 tuple_new_from_filename(const gchar *filename) |
150 { | 168 { |
151 gchar *scratch, *ext, *realfn; | 169 gchar *scratch, *ext, *realfn; |
152 Tuple *tuple; | 170 Tuple *tuple; |
158 g_return_val_if_fail(tuple != NULL, NULL); | 176 g_return_val_if_fail(tuple != NULL, NULL); |
159 | 177 |
160 realfn = g_filename_from_uri(filename, NULL, NULL); | 178 realfn = g_filename_from_uri(filename, NULL, NULL); |
161 | 179 |
162 scratch = g_path_get_basename(realfn ? realfn : filename); | 180 scratch = g_path_get_basename(realfn ? realfn : filename); |
163 tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, scratch); | 181 _tuple_associate_raw_string(tuple, FIELD_FILE_NAME, NULL, scratch); |
164 g_free(scratch); | 182 g_free(scratch); |
165 | 183 |
166 scratch = g_path_get_dirname(realfn ? realfn : filename); | 184 scratch = g_path_get_dirname(realfn ? realfn : filename); |
167 tuple_associate_string(tuple, FIELD_FILE_PATH, NULL, scratch); | 185 _tuple_associate_raw_string(tuple, FIELD_FILE_PATH, NULL, scratch); |
168 g_free(scratch); | 186 g_free(scratch); |
169 | 187 |
170 g_free(realfn); realfn = NULL; | 188 g_free(realfn); realfn = NULL; |
171 | 189 |
172 ext = strrchr(filename, '.'); | 190 ext = strrchr(filename, '.'); |
173 if (ext != NULL) { | 191 if (ext != NULL) { |
174 ++ext; | 192 ++ext; |
175 tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, scratch); | 193 _tuple_associate_raw_string(tuple, FIELD_FILE_EXT, NULL, scratch); |
176 } | 194 } |
177 | 195 |
178 return tuple; | 196 return tuple; |
179 } | 197 } |
180 | 198 |
252 return FALSE; | 270 return FALSE; |
253 | 271 |
254 if (string == NULL) | 272 if (string == NULL) |
255 value->value.string = NULL; | 273 value->value.string = NULL; |
256 else | 274 else |
257 value->value.string = g_strdup(string); | 275 value->value.string = str_to_utf8(string); |
258 | 276 |
259 TUPLE_UNLOCK_WRITE(); | 277 TUPLE_UNLOCK_WRITE(); |
260 return TRUE; | 278 return TRUE; |
261 } | 279 } |
262 | 280 |