Read mimeapps.list file.
Read MIME type associations from inilike.range.IniLikeReader, e.g. acquired from inilike.range.iniLikeFileReader or inilike.range.iniLikeStringReader.
Add desktopId as association for mimeType. Delete it from removed associations if listed. Note: This only changes the object, but not file itself.
Access "Added Associations" group of explicitly added associations.
Access "Desktop Applications" group of default associations.
Create empty "Added Associations" group if it does not exist.
Create empty "Default Applications" group if it does not exist.
Create empty "Removed Associations" group if it does not exist.
Explicitly remove desktopId association for mimeType. Delete it from added associations and default applications. Note: This only changes the object, but not file itself.
Access "Removed Associations" group of explicitily removed associations.
Set list of desktop ids as assocations for mimeType. This overwrites existing assocations. Note: This only changes the object, but not file itself.
Set desktopId as default application for mimeType. Set it as first element in the list of added associations. Delete it from removed associations if listed. Note: This only changes the object, but not file itself.
string content = `[Added Associations] text/plain=geany.desktop;kde4-kwrite.desktop; image/png=kde4-gwenview.desktop;gthumb.desktop; [Removed Associations] text/plain=libreoffice-writer.desktop; [Default Applications] text/plain=kde4-kate.desktop x-scheme-handler/http=chromium.desktop;iceweasel.desktop; [Unknown group] Key=Value`; auto mimeAppsList = new MimeAppsListFile(iniLikeStringReader(content)); assert(mimeAppsList.addedAssociations() !is null); assert(mimeAppsList.removedAssociations() !is null); assert(mimeAppsList.defaultApplications() !is null); assert(mimeAppsList.group("Unknown group") is null); assert(mimeAppsList.addedAssociations().appsForMimeType("text/plain").equal(["geany.desktop", "kde4-kwrite.desktop"])); assert(mimeAppsList.removedAssociations().appsForMimeType("text/plain").equal(["libreoffice-writer.desktop"])); assert(mimeAppsList.defaultApplications().appsForMimeType("x-scheme-handler/http").equal(["chromium.desktop", "iceweasel.desktop"])); content = `[Default Applications] text/plain=geany.desktop notmimetype=value `; assertThrown!IniLikeReadException(new MimeAppsListFile(iniLikeStringReader(content))); assertNotThrown(mimeAppsList = new MimeAppsListFile(iniLikeStringReader(content), null, IniLikeFile.ReadOptions(IniLikeGroup.InvalidKeyPolicy.save))); assert(mimeAppsList.defaultApplications().escapedValue("notmimetype") == "value");
Class represenation of single mimeapps.list file containing information about MIME type associations and default applications.