range of base application paths to check if this file belongs to one of them.
Desktop file ID or empty string if file does not have an ID.
string contents = `[Desktop Entry] Name=Program Type=Directory`; string[] appPaths; string filePath, nestedFilePath, wrongFilePath; version(Windows) { appPaths = [`C:\ProgramData\KDE\share\applications`, `C:\Users\username\.kde\share\applications`]; filePath = `C:\ProgramData\KDE\share\applications\example.desktop`; nestedFilePath = `C:\ProgramData\KDE\share\applications\kde\example.desktop`; wrongFilePath = `C:\ProgramData\desktop\example.desktop`; } else { appPaths = ["/usr/share/applications", "/usr/local/share/applications"]; filePath = "/usr/share/applications/example.desktop"; nestedFilePath = "/usr/share/applications/kde/example.desktop"; wrongFilePath = "/etc/desktop/example.desktop"; } auto df = new DesktopFile(iniLikeStringReader(contents), DesktopFile.ReadOptions.noOptions, nestedFilePath); assert(df.id(appPaths) == "kde-example.desktop"); df = new DesktopFile(iniLikeStringReader(contents), DesktopFile.ReadOptions.noOptions, filePath); assert(df.id(appPaths) == "example.desktop"); df = new DesktopFile(iniLikeStringReader(contents), DesktopFile.ReadOptions.noOptions, wrongFilePath); assert(df.id(appPaths).empty); df = new DesktopFile(iniLikeStringReader(contents), DesktopFile.ReadOptions.noOptions); assert(df.id(appPaths).empty);
applicationsPaths
See Desktop File ID