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/20 19:14:02
No need for braces. The rest of the code only use
gburanov
2015/04/22 14:21:55
Done.
| |
| 565 return mime_type; | 564 mime_type = _xdg_binary_or_text_fallback(data, bytes_read); |
| 565 } | |
| 566 | 566 |
| 567 return _xdg_binary_or_text_fallback(data, bytes_read); | 567 free (data); |
| 568 return mime_type; | |
| 568 } | 569 } |
| 569 | 570 |
| 570 const char * | 571 const char * |
| 571 xdg_mime_get_mime_type_from_file_name (const char *file_name) | 572 xdg_mime_get_mime_type_from_file_name (const char *file_name) |
| 572 { | 573 { |
| 573 const char *mime_type; | 574 const char *mime_type; |
| 574 | 575 |
| 575 xdg_mime_init (); | 576 xdg_mime_init (); |
| 576 | 577 |
| 577 if (_caches) | 578 if (_caches) |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 const char * | 926 const char * |
| 926 xdg_mime_get_generic_icon (const char *mime) | 927 xdg_mime_get_generic_icon (const char *mime) |
| 927 { | 928 { |
| 928 xdg_mime_init (); | 929 xdg_mime_init (); |
| 929 | 930 |
| 930 if (_caches) | 931 if (_caches) |
| 931 return _xdg_mime_cache_get_generic_icon (mime); | 932 return _xdg_mime_cache_get_generic_icon (mime); |
| 932 | 933 |
| 933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); | 934 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); |
| 934 } | 935 } |
| OLD | NEW |