annotate src/audacious/ui_albumart.c @ 4114:3218e86beed7

Fixes memory leak in playlist_add_files() function when using extension probing and trying to add file with unknown extension. (Bugzilla #44)
author Jussi Judin <jjudin+audacious@iki.fi>
date Tue, 25 Dec 2007 01:16:26 -0600
parents f985357757e0
children b87f8c707b7f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
1 /*
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
2 * Audacious: A cross-platform multimedia player
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
3 * Copyright (c) 2007 William Pitcock, Tony Vroon, George Averill,
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
5 *
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
6 * This program is free software; you can redistribute it and/or modify
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
7 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 2894
diff changeset
8 * the Free Software Foundation; under version 3 of the License.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
9 *
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
10 * This program is distributed in the hope that it will be useful,
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
13 * GNU General Public License for more details.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
14 *
2894
062324422c40 Backed out changeset 7dad846ec69940e4e905c357ae8dff81240b579b
William Pitcock <nenolod@atheme.org>
parents: 2862
diff changeset
15 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 2894
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
17 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
18 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
19 * Audacious or using our public API to be a derived work.
2442
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
20 */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
21
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
23 # include "config.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
24 #endif
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
25
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
26 #include <glib.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
27 #include <glib/gi18n.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
28 #include <gtk/gtk.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
29 #include <string.h>
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
30
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
31 #include "ui_fileinfopopup.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
32 #include "main.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
33 #include "ui_main.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
34 #include "playlist.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
35 #include "playback.h"
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
36
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
37 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
38 has_front_cover_extension(const gchar *name)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
39 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
40 char *ext;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
41
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
42 ext = strrchr(name, '.');
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
43 if (!ext) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
44 /* No file extension */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
45 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
46 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
47
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
48 return g_strcasecmp(ext, ".jpg") == 0 ||
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
49 g_strcasecmp(ext, ".jpeg") == 0 ||
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
50 g_strcasecmp(ext, ".png") == 0;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
51 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
52
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
53 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
54 cover_name_filter(const gchar *name, const gchar *filter, const gboolean ret_on_empty)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
55 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
56 gboolean result = FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
57 gchar **splitted;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
58 gchar *current;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
59 gchar *lname;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
60 gint i;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
61
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
62 if (!filter || strlen(filter) == 0) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
63 return ret_on_empty;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
64 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
65
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
66 splitted = g_strsplit(filter, ",", 0);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
67
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
68 lname = g_strdup(name);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
69 g_strdown(lname);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
70
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
71 for (i = 0; !result && (current = splitted[i]); i++) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
72 gchar *stripped = g_strstrip(g_strdup(current));
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
73 g_strdown(stripped);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
74
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
75 result = result || strstr(lname, stripped);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
76
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
77 g_free(stripped);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
78 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
79
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
80 g_free(lname);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
81 g_strfreev(splitted);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
82
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
83 return result;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
84 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
85
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
86 /* Check wether it's an image we want */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
87 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
88 is_front_cover_image(const gchar *imgfile)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
89 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
90 return cover_name_filter(imgfile, cfg.cover_name_include, TRUE) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
91 !cover_name_filter(imgfile, cfg.cover_name_exclude, FALSE);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
92 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
93
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
94 static gboolean
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
95 is_file_image(const gchar *imgfile, const gchar *file_name)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
96 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
97 char *imgfile_ext, *file_name_ext;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
98 size_t imgfile_len, file_name_len;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
99
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
100 imgfile_ext = strrchr(imgfile, '.');
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
101 if (!imgfile_ext) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
102 /* No file extension */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
103 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
104 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
105
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
106 file_name_ext = strrchr(file_name, '.');
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
107 if (!file_name_ext) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
108 /* No file extension */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
109 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
110 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
111
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
112 imgfile_len = (imgfile_ext - imgfile);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
113 file_name_len = (file_name_ext - file_name);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
114
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
115 if (imgfile_len == file_name_len) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
116 return (g_ascii_strncasecmp(imgfile, file_name, imgfile_len) == 0);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
117 } else {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
118 return FALSE;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
119 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
120 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
121
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
122 gchar*
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
123 fileinfo_recursive_get_image(const gchar* path,
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
124 const gchar* file_name, gint depth)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
125 {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
126 GDir *d;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
127
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
128 if (cfg.recurse_for_cover && depth > cfg.recurse_for_cover_depth)
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
129 return NULL;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
130
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
131 d = g_dir_open(path, 0, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
132
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
133 if (d) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
134 const gchar *f;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
135
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
136 if (cfg.use_file_cover && file_name) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
137 /* Look for images matching file name */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
138 while((f = g_dir_read_name(d))) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
139 gchar *newpath = g_strconcat(path, "/", f, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
140
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
141 if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
142 has_front_cover_extension(f) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
143 is_file_image(f, file_name)) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
144 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
145 return newpath;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
146 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
147
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
148 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
149 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
150 g_dir_rewind(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
151 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
152
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
153 /* Search for files using filter */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
154 while ((f = g_dir_read_name(d))) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
155 gchar *newpath = g_strconcat(path, "/", f, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
156
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
157 if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
158 has_front_cover_extension(f) &&
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
159 is_front_cover_image(f)) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
160 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
161 return newpath;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
162 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
163
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
164 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
165 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
166 g_dir_rewind(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
167
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
168 /* checks whether recursive or not. */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
169 if (!cfg.recurse_for_cover) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
170 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
171 return NULL;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
172 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
173
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
174 /* Descend into directories recursively. */
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
175 while ((f = g_dir_read_name(d))) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
176 gchar *newpath = g_strconcat(path, "/", f, NULL);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
177
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
178 if(g_file_test(newpath, G_FILE_TEST_IS_DIR)) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
179 gchar *tmp = fileinfo_recursive_get_image(newpath,
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
180 NULL, depth + 1);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
181 if(tmp) {
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
182 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
183 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
184 return tmp;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
185 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
186 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
187
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
188 g_free(newpath);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
189 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
190
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
191 g_dir_close(d);
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
192 }
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
193
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
194 return NULL;
44df6c17411b [svn] - split out albumart locating functions into a seperate file and make the public API available in util.h
nenolod
parents:
diff changeset
195 }