findAssociatedApplications

Find associated applications for given MIME type.

const(DesktopFile)[]
findAssociatedApplications
(
ListRange
CacheRange
)
if (
isForwardRange!ListRange &&
is(ElementType!ListRange : const(MimeAppsListFile))
&&
isForwardRange!CacheRange
&&
is(ElementType!CacheRange : const(MimeInfoCacheFile))
)

Parameters

mimeType string

MIME type or uri scheme handler in question.

mimeAppsListFiles ListRange

Range of MimeAppsListFile objects to use in searching.

mimeInfoCacheFiles CacheRange

Range of MimeInfoCacheFile objects to use in searching.

desktopFileProvider IDesktopFileProvider

Desktop file provider instance. Must be non-null.

Return Value

Type: const(DesktopFile)[]

Array of found desktopfile.file.DesktopFile objects capable of opening file of given MIME type or url of given scheme. Note: If no applications found for this mimeType, you may consider to use this function on parent MIME type.

Examples

auto desktopProvider = new DesktopFileProvider(["test/applications"]);
auto mimeAppsList = new MimeAppsListFile("test/applications/mimeapps.list");
auto mimeInfoCache = new MimeInfoCacheFile("test/applications/mimeinfo.cache");
assert(findAssociatedApplications("text/plain", [null, mimeAppsList], [null, mimeInfoCache], desktopProvider)
    .map!(d => d.displayName()).equal(["Geany", "Kate", "Emacs"]));
assert(findAssociatedApplications("application/nonexistent", [mimeAppsList], [mimeInfoCache], desktopProvider).length == 0);
assert(findAssociatedApplications("application/x-data", [mimeAppsList], [mimeInfoCache], desktopProvider).length == 0);

See Also

Meta