Skip to content

Commit 0906105

Browse files
committed
ViewClient: Prevents wrong interpretation of spaces in path
- Added install to Google Drive target
1 parent f092ee2 commit 0906105

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

AndroidViewClient/build.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
</filterchain>
1818
</loadfile>
1919

20+
<property name="avc.jar" value="bin/${avc.jarname}-${avc.version}.jar" />
2021
<target name="jar" depends="compile">
2122
<echo message="Creating ${avc.jarname} ${avc.version} jar ..." />
22-
<jar destfile="bin/${avc.jarname}-${avc.version}.jar">
23+
<jar destfile="${avc.jar}">
2324
<fileset dir="src/" excludes="**/*.java" />
2425
<fileset dir="." includes="tools/*" />
2526
<fileset dir="bin/classes" />
@@ -39,4 +40,8 @@
3940
<javac srcdir="src" destdir="bin/classes" />
4041
</target>
4142

43+
<target name="install" depends="jar">
44+
<mkdir dir="${gdrive.dest.dir}" />
45+
<copy file="${avc.jar}" todir="${gdrive.dest.dir}" />
46+
</target>
4247
</project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Culebra
22
avc.jarname=androidviewclient
3+
gdrive.dest.dir=${user.home}/Google Drive//Android/AndroidViewClient/bin/
4+

AndroidViewClient/src/com/dtmilano/android/viewclient/ViewClient.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.IOException;
77
import java.io.InputStream;
88
import java.io.OutputStream;
9+
import java.net.URLDecoder;
910
import java.util.ArrayList;
1011
import java.util.StringTokenizer;
1112
import java.util.jar.JarEntry;
@@ -128,24 +129,26 @@ public ViewClient(Command cmd, String[] args) throws IOException {
128129
if (args != null && args.length > 0) {
129130
mArgs = args;
130131
}
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"));
133135
if (DEBUG) {
134-
System.err.println("jar=" + file);
136+
System.err.println("jar=" + file.getCanonicalPath() + " exists? " + file.exists());
135137
}
136138

137139
try {
138140
mJar = new JarFile(file);
139141
} catch (ZipException e) {
140-
error("Tools should be started using the jar file.");
142+
error("Tools should be started using the jar file.", e);
141143
usage();
142144
}
143145

144146
final String entry = TOOLS + "/" + cmd.name().toLowerCase();
145147
final JarEntry jarEntry = mJar.getJarEntry(entry);
146148
if (jarEntry != null) {
147149
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
149152
mDest = new File(System.getProperty("user.home") + File.separator
150153
+ cmd.name().toLowerCase());
151154
final FileOutputStream fos = new java.io.FileOutputStream(mDest);
@@ -279,6 +282,11 @@ private static void error(String msg) {
279282
System.err.println(msg);
280283
}
281284

285+
private void error(String msg, Exception e) {
286+
error(msg);
287+
e.printStackTrace(System.err);
288+
}
289+
282290
private static void fatal(String msg) {
283291
error(msg);
284292
System.exit(1);

0 commit comments

Comments
 (0)