private static Path getDesktopDirectory() {
    if (SystemInfo.isWindows && JnaLoader.isLoaded()) {
      char[] path = new char[WinDef.MAX_PATH];
      WinNT.HRESULT res = Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_DESKTOP, null, ShlObj.SHGFP_TYPE_CURRENT, path);
      if (WinError.S_OK.equals(res)) {
        int len = 0;
        while (len < path.length && path[len] != 0) len++;
        return Path.of(new String(path, 0, len));
      }
    }
    else if (SystemInfo.isMac && JnaLoader.isLoaded()) {
      ID manager = Foundation.invoke(Foundation.getObjcClass("NSFileManager"), "defaultManager");
      ID url = Foundation.invoke(manager, "URLForDirectory:inDomain:appropriateForURL:create:error:",
        12 /*NSDesktopDirectory*/, 1 /*NSUserDomainMask*/, null, false, null);
      String path = Foundation.toStringViaUTF8(Foundation.invoke(url, "path"));
      if (path != null) {
        return Path.of(path);
      }
    }
    else if (SystemInfo.hasXdgOpen()) {
      String path = ExecUtil.execAndReadLine(new GeneralCommandLine("xdg-user-dir", "DESKTOP"));
      if (path != null && !path.isBlank()) {
        try {
          return Path.of(path);
        }
        catch (InvalidPathException e) {
          Logger.getInstance(GotoDesktopDirAction.class).error("str='" + path + "' JNU=" + System.getProperty("sun.jnu.encoding"), e);
        }
      }
    }

    return Path.of(SystemProperties.getUserHome(), "Desktop");
  }
private static Path getDesktopDirectory()