mime 0.1.1
Shared MIME-info Database specification implementation
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
This package provides sub packages which can be used individually:
mime:mimecache - A minimal D application.
mime:mimedatabase - A minimal D application.
mime:magic - A minimal D application.
Mime
Shared MIME-info database specification implementation in D programming language.
Examples
MimeCache
Run to detect mime type of README.md or other file using mime.cache file:
dub run mime:mimecache -- /usr/share/mime/mime.cache README.md
MimeDatabase
Print short information on all found MIME types.
dub run mime:mimedatabase -- --printDatabase=true
Run to detect mime types of files.
dub run mime:mimedatabase -- --file=README.md --file=source --file=.gitignore --file=lib/libmime.a
TODO
- Implement MIME type detection from file contents (via magic).
- Read MIME types from mime/packages sources (need xml library).
- Determine MIME type by XMLnamespace if document is xml (need streaming xml library).
- Implement merging of many files into one database (user defined one from .local/share/mime should be used before system-wide defined /usr/share/mime).
- Allow to create MIME types (need xml library) and call update-mime-database.
Interface and implementation discussion
Which interfaces library should provide? The obvious way is to make MimeType and MimeDatabase classes. But there're at least 3 ways to read mime database:
- From mime.cache. It lacks additional information (like comments, acronyms and additional fields), optimized for lookup, but not for storing MIME types as separate objects).
- From various generated files like globs, icons, magic, etc (not optimized, also lacks information, but easy to read).
- From mime/packages sources. It's straight-forward and the most complete (in sense it does not lose any information) way, but requires XML parsing.
All can be implemented as different MimeDatabase classes inherited the same interface.
What about thread safety?
MimeType matters:
- Should MimeType be class or struct?
- Should MimeType be independent from database it was read from?
- Should MimeType always preserve all information if it was loaded from xml source?
Should MimeDatabse detect MIME types for non-regular files? (inode/directory, etc.) Should MimeDatabse distinguish between text and binary data (text/plain vs application/octet-stream) when could not determine MIME type?
- Registered by Roman Chistokhodov
- 0.1.1 released 9 years ago
- FreeSlave/mime
- BSL-1.0
- Copyright © 2015, Roman Chistokhodov
- Authors:
- Sub packages:
- mime:mimecache, mime:mimedatabase, mime:magic
- Dependencies:
- none
- Versions:
-
0.5.2 2020-Sep-29 0.5.1 2018-Oct-20 0.5.0 2018-Oct-10 0.4.3 2018-May-04 0.4.2 2016-Sep-26 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
349 downloads total
-
- Score:
- 0.8
- Short URL:
- mime.dub.pm