Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ViewClient: Cleanup on exit

  • Loading branch information...
commit f092ee2d8f1ac2d6c7fc70ac7ff8160bafe10c34 1 parent b22c760
@dtmilano authored
View
6 AndroidViewClient/src/com/dtmilano/android/viewclient/ViewClient.java
@@ -40,6 +40,8 @@
private boolean mIsDestCreated = false;
+ private boolean mKeep = false;
+
/**
* Command arguments.
*/
@@ -143,6 +145,7 @@ public ViewClient(Command cmd, String[] args) throws IOException {
final JarEntry jarEntry = mJar.getJarEntry(entry);
if (jarEntry != null) {
final InputStream is = mJar.getInputStream(jarEntry);
+ // We cannot use /tmp or similar because sometimes it's mounted noexec
mDest = new File(System.getProperty("user.home") + File.separator
+ cmd.name().toLowerCase());
final FileOutputStream fos = new java.io.FileOutputStream(mDest);
@@ -153,6 +156,9 @@ public ViewClient(Command cmd, String[] args) throws IOException {
is.close();
mDest.setExecutable(true);
mIsDestCreated = true;
+ if (!mKeep) {
+ mDest.deleteOnExit();
+ }
}
else {
fatal("Cannot extract " + entry + " from jar");
Please sign in to comment.
Something went wrong with that request. Please try again.