desktopId

  1. string desktopId(string fileName, Range appsPaths)
    string
    desktopId
    (
    Range
    )
    (
    string fileName
    ,
    Range appsPaths
    )
    if (
    isInputRange!Range &&
    is(ElementType!Range : string)
    )
  2. string desktopId(string fileName)

Parameters

fileName string

Desktop file.

appsPaths Range

Range of base application paths.

Return Value

Type: string

Desktop file ID or empty string if file does not have an ID.

Examples

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";
}

assert(desktopId(nestedFilePath, appPaths) == "kde-example.desktop");
assert(desktopId(filePath, appPaths) == "example.desktop");
assert(desktopId(wrongFilePath, appPaths).empty);
assert(desktopId("", appPaths).empty);

See Also

desktopfile.paths.applicationsPaths

Meta