mime 0.4.3

Shared MIME-info Database specification implementation


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Mime

Shared MIME-info database specification implementation in D programming language. Shared MIME-info database helps to determine media type of file by its name or contents.

Build Status Coverage Status

Online documentation

Features

Implemented features

  • Reading and using mime.cache files to match file names against glob patterns, match file contents against magic rules, resolve aliases and find mime type parents.
  • Reading various shared MIME-info database files in mime/ subfolder, e.g. globs2, magic and others.
  • treemagic support.

Missing features

  • Reading MIME types from mime/packages sources and mime/MEDIA folders (requires xml library).
  • Determining MIME type by XMLnamespace if document is xml (requires streaming xml library).

Examples

Mime Database

Run to detect mime types of files.

dub examples/database.d detect README.md source .gitignore lib/libmime.a /bin/sh /var/run/acpid.socket dub.json /dev/sda

Automated mime path detection works only on Freedesktop platforms. On other systmes or for testing purposes it's possible to use mimepath option to set alternate path to mime/ subfolder. E.g. on Windows with KDE installed it would be:

dub examples/database.d --mimepath=C:\ProgramData\KDE\share\mime detect README.md source .gitignore lib/mime.lib C:/Windows/System32/notepad.exe dub.json

Run to print info about MIME types:

dub examples/database.d info application/pdf application/x-executable image/png text/plain text/html text/xml

Run to resolve aliases:

dub examples/database.d resolve application/wwf application/x-pdf application/pgp text/rtf text/xml

Mime Test

Run to test if this library is capable of parsing your local shared MIME-info database:

dub examples/test.d

Run to see names of parsed files:

dub examples/test.d --verbose

As with mimedatabase example you may specify paths to mime folder(s) via command line:

dub examples/test.d --mimepath=C:\ProgramData\KDE\share\mime
Authors:
  • Roman Chistokhodov
Dependencies:
xdgpaths
Versions:
0.4.3 2018-May-04
0.4.2 2016-Sep-26
0.4.1 2016-Aug-01
0.4.0 2016-Jul-08
0.3.3 2016-Apr-19
Show all 14 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 2 downloads this month

  • 270 downloads total

Score:
0.8
Short URL:
mime.dub.pm