Index: base/third_party/xdg_mime/xdgmime.c |
=================================================================== |
--- base/third_party/xdg_mime/xdgmime.c (revision 150109) |
+++ base/third_party/xdg_mime/xdgmime.c (working copy) |
@@ -26,7 +26,7 @@ |
*/ |
#ifdef HAVE_CONFIG_H |
-#include "config.h" |
+#include <config.h> |
#endif |
#include "xdgmime.h" |
@@ -64,6 +64,8 @@ |
static int n_caches = 0; |
const char xdg_mime_type_unknown[] = "application/octet-stream"; |
+const char xdg_mime_type_empty[] = "application/x-zerosize"; |
+const char xdg_mime_type_textplain[] = "text/plain"; |
enum |
@@ -165,7 +167,7 @@ |
strcpy (file_name, directory); strcat (file_name, "/mime/globs2"); |
if (stat (file_name, &st) == 0) |
{ |
- _xdg_mime_glob_read_from_file (global_hash, file_name); |
+ _xdg_mime_glob_read_from_file (global_hash, file_name, TRUE); |
xdg_dir_time_list_add (file_name, st.st_mtime); |
} |
else |
@@ -175,7 +177,7 @@ |
strcpy (file_name, directory); strcat (file_name, "/mime/globs"); |
if (stat (file_name, &st) == 0) |
{ |
- _xdg_mime_glob_read_from_file (global_hash, file_name); |
+ _xdg_mime_glob_read_from_file (global_hash, file_name, FALSE); |
xdg_dir_time_list_add (file_name, st.st_mtime); |
} |
else |
@@ -467,17 +469,23 @@ |
{ |
const char *mime_type; |
+ if (len == 0) |
+ { |
+ *result_prio = 100; |
+ return XDG_MIME_TYPE_EMPTY; |
+ } |
+ |
xdg_mime_init (); |
if (_caches) |
- return _xdg_mime_cache_get_mime_type_for_data (data, len, result_prio); |
+ mime_type = _xdg_mime_cache_get_mime_type_for_data (data, len, result_prio); |
+ else |
+ mime_type = _xdg_mime_magic_lookup_data (global_magic, data, len, result_prio, NULL, 0); |
- mime_type = _xdg_mime_magic_lookup_data (global_magic, data, len, result_prio, NULL, 0); |
- |
if (mime_type) |
return mime_type; |
- return XDG_MIME_TYPE_UNKNOWN; |
+ return _xdg_binary_or_text_fallback(data, len); |
} |
const char * |
@@ -556,7 +564,7 @@ |
if (mime_type) |
return mime_type; |
- return XDG_MIME_TYPE_UNKNOWN; |
+ return _xdg_binary_or_text_fallback(data, bytes_read); |
} |
const char * |