Skip to content

Commit

Permalink
Handle jnlp filename with space for shortcuts (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
douph1 authored and sclassen committed Apr 18, 2019
1 parent 07161bf commit 77e8d3c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions netx/net/sourceforge/jnlp/util/WindowsDesktopEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
Expand All @@ -35,6 +36,7 @@ public class WindowsDesktopEntry implements GenericDesktopEntry {

private final JNLPFile file;
private final String iconLocation;
private static final String DOUBLE_QUOTE = "\"";

public WindowsDesktopEntry(JNLPFile file) {
this.file = file;
Expand All @@ -59,7 +61,7 @@ public File getDesktopIconFile() {
public void createShortcutOnWindowsDesktop() throws IOException {
String path = getDesktopLnkPath();
String JavaWsBin = XDesktopEntry.getJavaWsBin();
ShellLink sl = ShellLink.createLink(JavaWsBin).setCMDArgs(file.getSourceLocation().toString());
ShellLink sl = ShellLink.createLink(JavaWsBin).setCMDArgs(quoted(file.getSourceLocation()));
if (iconLocation != null) {
sl.setIconLocation(iconLocation);
}
Expand Down Expand Up @@ -90,9 +92,9 @@ public void createWindowsMenu() throws IOException {
menuDir.mkdir();
}
final String JavaWsBin = XDesktopEntry.getJavaWsBin();
final ShellLink sl = ShellLink.createLink(JavaWsBin).setCMDArgs(file.getSourceLocation().toString());
final ShellLink sl = ShellLink.createLink(JavaWsBin).setCMDArgs(quoted(file.getSourceLocation()));
// setup uninstall shortcut
final ShellLink ul = ShellLink.createLink(JavaWsBin).setCMDArgs("-Xclearcache " + file.getFileLocation().toString());
final ShellLink ul = ShellLink.createLink(JavaWsBin).setCMDArgs("-Xclearcache " + quoted(file.getFileLocation()));
if (iconLocation != null) {
sl.setIconLocation(iconLocation);
ul.setIconLocation(iconLocation);
Expand Down Expand Up @@ -165,4 +167,8 @@ private static enum ManageMode {
A
}

private String quoted(URL url) {
return DOUBLE_QUOTE + url + DOUBLE_QUOTE;
}

}

0 comments on commit 77e8d3c

Please sign in to comment.