changeset 2989:15f6c9949cde trunk

Add and use find_path_recursively() which search the FS without using VFS (for GTK).
author William Pitcock <nenolod@atheme-project.org>
date Thu, 05 Jul 2007 01:40:11 -0500
parents 43a075cb5c81
children 3a907327e228
files src/audacious/util.c src/audacious/util.h src/audacious/widgets/skin.c
diffstat 3 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/util.c	Thu Jul 05 01:26:16 2007 -0500
+++ b/src/audacious/util.c	Thu Jul 05 01:40:11 2007 -0500
@@ -79,14 +79,14 @@
         return TRUE;
     }
 
-    if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+    if (vfs_file_test(path, G_FILE_TEST_IS_REGULAR)) {
         if (!strcasecmp(basename, context->to_match)) {
             context->match = g_strdup(path);
             context->found = TRUE;
             return TRUE;
         }
     }
-    else if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
+    else if (vfs_file_test(path, G_FILE_TEST_IS_DIR)) {
         dir_foreach(path, find_file_func, context, NULL);
         if (context->found)
             return TRUE;
@@ -99,19 +99,38 @@
 find_file_recursively(const gchar * path, const gchar * filename)
 {
     FindFileContext context;
-    gchar *out;
+    gchar *out = NULL;
 
     context.to_match = filename;
     context.match = NULL;
     context.found = FALSE;
 
     dir_foreach(path, find_file_func, &context, NULL);
-    out = g_strconcat("file:", context.match);
-    g_free(context.match);
+
+    if (context.match)
+    {
+        out = g_filename_to_uri(context.match, NULL, NULL);
+        g_free(context.match);
+    }
 
     return out;
 }
 
+gchar *
+find_path_recursively(const gchar * path, const gchar * filename)
+{
+    FindFileContext context;
+    gchar *out = NULL;
+
+    context.to_match = filename;
+    context.match = NULL;
+    context.found = FALSE;
+
+    dir_foreach(path, find_file_func, &context, NULL);
+
+    return context.match;
+}
+
 
 typedef enum {
     ARCHIVE_UNKNOWN = 0,
--- a/src/audacious/util.h	Thu Jul 05 01:26:16 2007 -0500
+++ b/src/audacious/util.h	Thu Jul 05 01:40:11 2007 -0500
@@ -45,6 +45,7 @@
 
 
 gchar *find_file_recursively(const gchar * dirname, const gchar * file);
+gchar *find_path_recursively(const gchar * dirname, const gchar * file);
 void del_directory(const gchar * dirname);
 gboolean dir_foreach(const gchar * path, DirForeachFunc function,
                      gpointer user_data, GError ** error);
--- a/src/audacious/widgets/skin.c	Thu Jul 05 01:26:16 2007 -0500
+++ b/src/audacious/widgets/skin.c	Thu Jul 05 01:40:11 2007 -0500
@@ -277,7 +277,7 @@
     gint i;
 
     for (i = 0; basenames[i]; i++)
-    if (!(filename = find_file_recursively(dirname, basenames[i]))) 
+    if (!(filename = find_path_recursively(dirname, basenames[i]))) 
         g_free(filename);
     else
         return filename;