comparison src/audacious/tuple.c @ 3301:008530664ba1 trunk

Add tuple_new_from_filename() which creates a new tuple with file-name, file-path and file-ext.
author Christian Birchinger <joker@netswarm.net>
date Fri, 10 Aug 2007 14:39:42 +0200
parents b78d3197c70d
children eaf68ed98166
comparison
equal deleted inserted replaced
3299:4ced71e14fcb 3301:008530664ba1
81 tuple->dict = mowgli_dictionary_create(g_ascii_strcasecmp); 81 tuple->dict = mowgli_dictionary_create(g_ascii_strcasecmp);
82 82
83 return tuple; 83 return tuple;
84 } 84 }
85 85
86 Tuple *
87 tuple_new_from_filename(gchar *filename)
88 {
89 gchar *scratch, *ext;
90 Tuple *tuple;
91
92 g_return_val_if_fail(filename != NULL, NULL);
93
94 tuple = tuple_new();
95
96 g_return_val_if_fail(tuple != NULL, NULL);
97
98 scratch = g_path_get_basename(filename);
99 tuple_associate_string(tuple, "file-name", scratch);
100 g_free(scratch);
101
102 scratch = g_path_get_dirname(filename);
103 tuple_associate_string(tuple, "file-path", scratch);
104 g_free(scratch);
105
106 ext = strrchr(filename, '.');
107 if (ext != NULL) {
108 ++ext;
109 tuple_associate_string(tuple, "file-ext", scratch);
110 }
111
112 return tuple;
113 }
114
86 gboolean 115 gboolean
87 tuple_associate_string(Tuple *tuple, const gchar *field, const gchar *string) 116 tuple_associate_string(Tuple *tuple, const gchar *field, const gchar *string)
88 { 117 {
89 TupleValue *value; 118 TupleValue *value;
90 119