Permalink
Browse files

ViewClient: Cleanup on exit

  • Loading branch information...
1 parent b22c760 commit f092ee2d8f1ac2d6c7fc70ac7ff8160bafe10c34 @dtmilano committed May 2, 2013
Showing with 6 additions and 0 deletions.
  1. +6 −0 AndroidViewClient/src/com/dtmilano/android/viewclient/ViewClient.java
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");

0 comments on commit f092ee2

Please sign in to comment.