Mercurial > audlegacy
diff src/audacious/util.c @ 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 |
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,