mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-07 16:38:43 +02:00
xdgmime: Add better detection for text vs. binary and zero-sized files
This detects zero-sized files to return the special-case "application/x-zerosize" mime-type, as well as trying to differentiate unknown file types based on their first 128 bytes of data, so that text editors can automatically handle unknown text files. Based on: https://cgit.freedesktop.org/xdg/xdgmime/commit/?id=5181175d5fdaa3832b0fd094cda0120b1fe92af6 https://cgit.freedesktop.org/xdg/xdgmime/commit/?id=9c5802b8da56187c5c6abaf70042d14b12d832a9 https://bugzilla.gnome.org/show_bug.cgi?id=795544
This commit is contained in:
committed by
Emmanuele Bassi
parent
d0a48f26c7
commit
1c177ce0ab
@@ -66,6 +66,8 @@ typedef void (*XdgMimeDestroy) (void *user_data);
|
||||
#define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
|
||||
#define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
|
||||
#define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
|
||||
#define xdg_mime_type_empty XDG_ENTRY(type_empty)
|
||||
#define xdg_mime_type_textplain XDG_ENTRY(type_textplain)
|
||||
#define xdg_mime_get_icon XDG_ENTRY(get_icon)
|
||||
#define xdg_mime_get_generic_icon XDG_ENTRY(get_generic_icon)
|
||||
|
||||
@@ -75,7 +77,11 @@ typedef void (*XdgMimeDestroy) (void *user_data);
|
||||
#endif
|
||||
|
||||
extern const char xdg_mime_type_unknown[];
|
||||
extern const char xdg_mime_type_empty[];
|
||||
extern const char xdg_mime_type_textplain[];
|
||||
#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
|
||||
#define XDG_MIME_TYPE_EMPTY xdg_mime_type_empty
|
||||
#define XDG_MIME_TYPE_TEXTPLAIN xdg_mime_type_textplain
|
||||
|
||||
const char *xdg_mime_get_mime_type_for_data (const void *data,
|
||||
size_t len,
|
||||
|
Reference in New Issue
Block a user