| OLD | NEW |
| 1 /* -*- mode: C; c-file-style: "gnu" -*- */ | 1 /* -*- mode: C; c-file-style: "gnu" -*- */ |
| 2 /* xdgmime.c: XDG Mime Spec mime resolver. Based on version 0.11 of the spec. | 2 /* xdgmime.c: XDG Mime Spec mime resolver. Based on version 0.11 of the spec. |
| 3 * | 3 * |
| 4 * More info can be found at http://www.freedesktop.org/standards/ | 4 * More info can be found at http://www.freedesktop.org/standards/ |
| 5 * | 5 * |
| 6 * Copyright (C) 2003,2004 Red Hat, Inc. | 6 * Copyright (C) 2003,2004 Red Hat, Inc. |
| 7 * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu> | 7 * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu> |
| 8 * | 8 * |
| 9 * Licensed under the Academic Free License version 2.0 | 9 * Licensed under the Academic Free License version 2.0 |
| 10 * Or under the following terms: | 10 * Or under the following terms: |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 if (ferror (file)) | 551 if (ferror (file)) |
| 552 { | 552 { |
| 553 free (data); | 553 free (data); |
| 554 fclose (file); | 554 fclose (file); |
| 555 return XDG_MIME_TYPE_UNKNOWN; | 555 return XDG_MIME_TYPE_UNKNOWN; |
| 556 } | 556 } |
| 557 | 557 |
| 558 mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, | 558 mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, |
| 559 mime_types, n); | 559 mime_types, n); |
| 560 | 560 |
| 561 free (data); | |
| 562 fclose (file); | 561 fclose (file); |
| 563 | 562 |
| 564 if (mime_type) | 563 if (!mime_type) |
| 565 return mime_type; | 564 mime_type = _xdg_binary_or_text_fallback(data, bytes_read); |
| 566 | 565 |
| 567 return _xdg_binary_or_text_fallback(data, bytes_read); | 566 free (data); |
| 567 return mime_type; |
| 568 } | 568 } |
| 569 | 569 |
| 570 const char * | 570 const char * |
| 571 xdg_mime_get_mime_type_from_file_name (const char *file_name) | 571 xdg_mime_get_mime_type_from_file_name (const char *file_name) |
| 572 { | 572 { |
| 573 const char *mime_type; | 573 const char *mime_type; |
| 574 | 574 |
| 575 xdg_mime_init (); | 575 xdg_mime_init (); |
| 576 | 576 |
| 577 if (_caches) | 577 if (_caches) |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 const char * | 925 const char * |
| 926 xdg_mime_get_generic_icon (const char *mime) | 926 xdg_mime_get_generic_icon (const char *mime) |
| 927 { | 927 { |
| 928 xdg_mime_init (); | 928 xdg_mime_init (); |
| 929 | 929 |
| 930 if (_caches) | 930 if (_caches) |
| 931 return _xdg_mime_cache_get_generic_icon (mime); | 931 return _xdg_mime_cache_get_generic_icon (mime); |
| 932 | 932 |
| 933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); | 933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); |
| 934 } | 934 } |
| OLD | NEW |