Skip to content

Commit f092ee2

Browse files
committed
ViewClient: Cleanup on exit
1 parent b22c760 commit f092ee2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ private enum Command {
4040

4141
private boolean mIsDestCreated = false;
4242

43+
private boolean mKeep = false;
44+
4345
/**
4446
* Command arguments.
4547
*/
@@ -143,6 +145,7 @@ public ViewClient(Command cmd, String[] args) throws IOException {
143145
final JarEntry jarEntry = mJar.getJarEntry(entry);
144146
if (jarEntry != null) {
145147
final InputStream is = mJar.getInputStream(jarEntry);
148+
// We cannot use /tmp or similar because sometimes it's mounted noexec
146149
mDest = new File(System.getProperty("user.home") + File.separator
147150
+ cmd.name().toLowerCase());
148151
final FileOutputStream fos = new java.io.FileOutputStream(mDest);
@@ -153,6 +156,9 @@ public ViewClient(Command cmd, String[] args) throws IOException {
153156
is.close();
154157
mDest.setExecutable(true);
155158
mIsDestCreated = true;
159+
if (!mKeep) {
160+
mDest.deleteOnExit();
161+
}
156162
}
157163
else {
158164
fatal("Cannot extract " + entry + " from jar");

0 commit comments

Comments
 (0)