MimeInfoCacheFile

Class represenation of single mimeinfo.cache file containing information about MIME type associations. Note: Unlike MimeAppsListFile this class does not provide functions for associations update. This is because mimeinfo.cache files should be updated by update-desktop-database utility from desktop-file-utils.

Constructors

this
this(string fileName, ReadOptions readOptions)

Read MIME Cache from file.

this
this()

Constructs MimeInfoCacheFile with empty MIME Cache group.

this
this(IniLikeReader reader, string fileName, ReadOptions readOptions)

Read MIME Cache from inilike.range.IniLikeReader, e.g. acquired from inilike.range.iniLikeFileReader or inilike.range.iniLikeStringReader.

Alias This

mimeCache

Alias for easy access to "MIME Cache" group.

Members

Functions

createGroupByName
IniLikeGroup createGroupByName(string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
mimeCache
inout(MimeAppsGroup) mimeCache()

Access "MIME Cache" group.

Examples

    string content =
`[Some group]
Key=Value
`;
    assertThrown!IniLikeReadException(new MimeInfoCacheFile(iniLikeStringReader(content)));

    content =
`[MIME Cache]
text/plain=geany.desktop;kde4-kwrite.desktop;
image/png=kde4-gwenview.desktop;gthumb.desktop;
`;

    auto mimeInfoCache = new MimeInfoCacheFile(iniLikeStringReader(content));
    assert(mimeInfoCache.appsForMimeType("text/plain").equal(["geany.desktop", "kde4-kwrite.desktop"]));
    assert(mimeInfoCache.appsForMimeType("image/png").equal(["kde4-gwenview.desktop", "gthumb.desktop"]));
    assert(mimeInfoCache.appsForMimeType("application/nonexistent").empty);

    content =
`[MIME Cache]
text/plain=geany.desktop;
notmimetype=value
`;
    assertThrown!IniLikeReadException(new MimeInfoCacheFile(iniLikeStringReader(content)));
    assertNotThrown(mimeInfoCache = new MimeInfoCacheFile(iniLikeStringReader(content), null, IniLikeFile.ReadOptions(IniLikeGroup.InvalidKeyPolicy.save)));
    assert(mimeInfoCache.mimeCache.escapedValue("notmimetype") == "value");

Meta