Chromium Code Reviews| 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) { |
|
Lei Zhang
2015/04/16 18:31:35
So how about:
if (!mime_type)
mime_type = _xdg_
| |
| 564 free (data); | |
| 565 return mime_type; | 565 return mime_type; |
| 566 } | |
| 566 | 567 |
| 567 return _xdg_binary_or_text_fallback(data, bytes_read); | 568 mime_type = _xdg_binary_or_text_fallback(data, bytes_read); |
| 569 free (data); | |
| 570 return mime_type; | |
| 568 } | 571 } |
| 569 | 572 |
| 570 const char * | 573 const char * |
| 571 xdg_mime_get_mime_type_from_file_name (const char *file_name) | 574 xdg_mime_get_mime_type_from_file_name (const char *file_name) |
| 572 { | 575 { |
| 573 const char *mime_type; | 576 const char *mime_type; |
| 574 | 577 |
| 575 xdg_mime_init (); | 578 xdg_mime_init (); |
| 576 | 579 |
| 577 if (_caches) | 580 if (_caches) |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 const char * | 928 const char * |
| 926 xdg_mime_get_generic_icon (const char *mime) | 929 xdg_mime_get_generic_icon (const char *mime) |
| 927 { | 930 { |
| 928 xdg_mime_init (); | 931 xdg_mime_init (); |
| 929 | 932 |
| 930 if (_caches) | 933 if (_caches) |
| 931 return _xdg_mime_cache_get_generic_icon (mime); | 934 return _xdg_mime_cache_get_generic_icon (mime); |
| 932 | 935 |
| 933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); | 936 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); |
| 934 } | 937 } |
| OLD | NEW |