General TC > Programming & Scripting - Unofficial
minimalistic approach to MIME types / filetype associations
mocore:
thanks!!! ...
--- Quote from: jazzbiker on March 12, 2020, 02:27:33 PM ---Well, just like the deep breath of clear air, thanks a lot!
--- End quote ---
+1
.. ftr the git hub link is mort
this is the current working url
https://gitlab.com/GNUser/tinyopen
perhaps this should/could be included in tinyopen.tcz.info
GNUser:
You're welcome, mocore. The latest version is 5.0 is available in the TCL13.1 x86_64 repository and has the correct (gitlab) url.
mocore:
hi ... after some reading
@ https://joeyh.name/code/moreutils/
--- Quote ---Rejected tools
(Some of these rejections may be reconsidered later.)
- mime
determines the mime type of a file using the gnome mine database
The File::MimeInfo perl module has a mimetype that works like this, and uses the freedesktop.org mime database, same as GNOME.
file -bi can do this too.
--- End quote ---
i wondered if the line @ https://gitlab.com/GNUser/tinyopen/-/blob/master/tinyopen/tinyopen?ref_type=heads#L42
(coincidentally note the line number :o )
--- Code: --- mimetype="$(gio info "$1" | grep '::content-type' | cut -d' ' -f4)"
--- End code ---
it might be possible?
to replace
gio info "$1" ...ect
with
file -bi "$1" ...?? (from file.tcz) ...
which apparently uses lib magic , and [1]appears to be smaller :D
any one know ? (or care to investigate?? (s)trace?..)
what method dose the current gio solution use ? to get the mime
???
[1] https://forum.tinycorelinux.net/index.php/topic,27303.0.html
GNUser:
It's certainly possible to use file rather than gio to get the mimetype. I went with gio because glib2.tcz (which provides gio) seemed to me more likely to already be loaded on someone's machine than file.tcz.
I'm honestly not sure how gio does its job done. But it seems to always get it right.
mocore:
--- Quote from: GNUser on October 02, 2024, 07:43:37 PM ---I went with gio because glib2.tcz (which provides gio) seemed to me more likely to already be loaded on someone's machine than file.tcz.
I'm honestly not sure how gio does its job done.
But it seems to always get it right.
--- End quote ---
ahh (i had not realized) that was the method used by linopen
https://github.com/Cloudef/PKGBUILDS/blob/master/linopen/open#L90
--- Code: ---$(file -L -b --mime-type "$1")
--- End code ---
--- Quote from: GNUser on October 02, 2024, 07:43:37 PM ---I'm honestly not sure how gio does its job done.
--- End quote ---
any hints on how to find out
i had browsed and grep'ed the source a bit
and run strace ( which seams to indicate it try's a opening files (if they exists) containing some kind of db
which begs the question is a binary (gio/file) dependency required to fine the mime of a file ??
so i started a topic ;D https://forum.tinycorelinux.net/index.php/topic,27304.0.html
--- Quote from: GNUser on October 02, 2024, 07:43:37 PM ---But it seems to always get it right.
--- End quote ---
i briefly compared file and gio and they did'nt reach the same conclusion (for a markdown file 'text/markdown' / 'text/plain' same difference relay)
though perhaps this discrepancy is explained by age of the data used ?idk
https://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version