GNOME Bugzilla – Bug 795544
Add binary/textfile/zero size detection
Last modified: 2018-05-10 11:00:44 UTC
This would allow GIO to detect zero-sized files, and differentiate most binary and text files, and thus offer opening in a text editor for unknown text file types. See those 2 commits for details: https://cgit.freedesktop.org/xdg/xdgmime/commit/?id=5181175d5fdaa3832b0fd094cda0120b1fe92af6 https://cgit.freedesktop.org/xdg/xdgmime/commit/?id=9c5802b8da56187c5c6abaf70042d14b12d832a9 See also for possible caveat: https://bugs.freedesktop.org/show_bug.cgi?id=97372
What exactly are you proposing here?
Adding pretty much the same code as above to GLib's outdated copy so we can detect unknown mime-types a bit better.
Oh, just updating gio/xdgmime from upstream? Sure. Patch welcome; I should be able to review it and get it in fairly fast. Is it the kind of thing you’d want backporting to glib-2-56 too?
(In reply to Philip Withnall from comment #3) > Oh, just updating gio/xdgmime from upstream? Sure. Patch welcome; I should > be able to review it and get it in fairly fast. Huh, no, Matthias wasn't interested in having the 2 copies of that code synchronised and they've diverged a lot since GIO appeared. So it would be applying that patch manually to our old and thoroughly modified copy. > Is it the kind of thing you’d want backporting to glib-2-56 too? It might be safe, we'll see when testing.
Created attachment 371617 [details] [review] 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
Review of attachment 371617 [details] [review]: Looks good
Attachment 371617 [details] pushed as 1c177ce - xdgmime: Add better detection for text vs. binary and zero-sized files