diff options
Diffstat (limited to 'gio/xdgmime/xdgmime.c')
-rw-r--r-- | gio/xdgmime/xdgmime.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c index 9bb93f791..770a4dd0b 100644 --- a/gio/xdgmime/xdgmime.c +++ b/gio/xdgmime/xdgmime.c @@ -20,10 +20,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see <http://www.gnu.org/licenses/>. + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "xdgmime.h" #include "xdgmimeint.h" @@ -134,7 +138,8 @@ xdg_dir_time_list_free (XdgDirTimeList *list) } static int -xdg_mime_init_from_directory (const char *directory) +xdg_mime_init_from_directory (const char *directory, + void *user_data) { char *file_name; struct stat st; @@ -400,10 +405,11 @@ xdg_check_file (const char *file_path, static int xdg_check_dir (const char *directory, - int *invalid_dir_list) + void *user_data) { int invalid, exists; char *file_name; + int* invalid_dir_list = user_data; assert (directory != NULL); @@ -458,8 +464,7 @@ xdg_check_dirs (void) for (list = dir_time_list; list; list = list->next) list->checked = XDG_CHECKED_UNCHECKED; - xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_check_dir, - &invalid_dir_list); + xdg_run_command_on_dirs (xdg_check_dir, &invalid_dir_list); if (invalid_dir_list) return TRUE; @@ -515,8 +520,7 @@ xdg_mime_init (void) icon_list = _xdg_mime_icon_list_new (); generic_icon_list = _xdg_mime_icon_list_new (); - xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_mime_init_from_directory, - NULL); + xdg_run_command_on_dirs (xdg_mime_init_from_directory, NULL); need_reread = FALSE; } @@ -621,13 +625,13 @@ xdg_mime_get_mime_type_for_file (const char *file_name, mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, mime_types, n); + if (!mime_type) + mime_type = _xdg_binary_or_text_fallback (data, bytes_read); + free (data); fclose (file); - if (mime_type) - return mime_type; - - return _xdg_binary_or_text_fallback(data, bytes_read); + return mime_type; } const char * |