|
6 | 6 | import java.io.IOException; |
7 | 7 | import java.io.InputStream; |
8 | 8 | import java.io.OutputStream; |
| 9 | +import java.net.URLDecoder; |
9 | 10 | import java.util.ArrayList; |
10 | 11 | import java.util.StringTokenizer; |
11 | 12 | import java.util.jar.JarEntry; |
@@ -128,24 +129,26 @@ public ViewClient(Command cmd, String[] args) throws IOException { |
128 | 129 | if (args != null && args.length > 0) { |
129 | 130 | mArgs = args; |
130 | 131 | } |
131 | | - final File file = new File(ViewClient.class.getProtectionDomain().getCodeSource() |
132 | | - .getLocation().getPath()); |
| 132 | + final File file = new File(URLDecoder.decode(ViewClient.class.getProtectionDomain() |
| 133 | + .getCodeSource() |
| 134 | + .getLocation().getPath(), "UTF-8")); |
133 | 135 | if (DEBUG) { |
134 | | - System.err.println("jar=" + file); |
| 136 | + System.err.println("jar=" + file.getCanonicalPath() + " exists? " + file.exists()); |
135 | 137 | } |
136 | 138 |
|
137 | 139 | try { |
138 | 140 | mJar = new JarFile(file); |
139 | 141 | } catch (ZipException e) { |
140 | | - error("Tools should be started using the jar file."); |
| 142 | + error("Tools should be started using the jar file.", e); |
141 | 143 | usage(); |
142 | 144 | } |
143 | 145 |
|
144 | 146 | final String entry = TOOLS + "/" + cmd.name().toLowerCase(); |
145 | 147 | final JarEntry jarEntry = mJar.getJarEntry(entry); |
146 | 148 | if (jarEntry != null) { |
147 | 149 | final InputStream is = mJar.getInputStream(jarEntry); |
148 | | - // We cannot use /tmp or similar because sometimes it's mounted noexec |
| 150 | + // We cannot use /tmp or similar because sometimes it's mounted |
| 151 | + // noexec |
149 | 152 | mDest = new File(System.getProperty("user.home") + File.separator |
150 | 153 | + cmd.name().toLowerCase()); |
151 | 154 | final FileOutputStream fos = new java.io.FileOutputStream(mDest); |
@@ -279,6 +282,11 @@ private static void error(String msg) { |
279 | 282 | System.err.println(msg); |
280 | 283 | } |
281 | 284 |
|
| 285 | + private void error(String msg, Exception e) { |
| 286 | + error(msg); |
| 287 | + e.printStackTrace(System.err); |
| 288 | + } |
| 289 | + |
282 | 290 | private static void fatal(String msg) { |
283 | 291 | error(msg); |
284 | 292 | System.exit(1); |
|
0 commit comments