MimeInfoCacheFile

Class represenation of single mimeinfo.cache file containing information about MIME type associations.

Constructors

this
this(string fileName)

Read MIME Cache from file.

this
this()

Constructs MimeInfoCacheFile with empty MIME Cache group.

this
this(IniLikeReader reader, string fileName)

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

Alias This

mimeCache

Alias for easy access to "MIME Cache" group.

Members

Functions

addCommentForGroup
void addCommentForGroup(string comment, IniLikeGroup currentGroup, string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
addKeyValueForGroup
void addKeyValueForGroup(string key, string value, IniLikeGroup currentGroup, string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
createGroup
IniLikeGroup createGroup(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!IniLikeException(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!IniLikeException(new MimeInfoCacheFile(iniLikeStringReader(content)));

Meta