forked from I2P_Developers/i2p.i2p
more aggressively delete the temp lib file
This commit is contained in:
@ -483,10 +483,11 @@ public class CPUID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File outFile = null;
|
File outFile = null;
|
||||||
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
InputStream libStream = resource.openStream();
|
InputStream libStream = resource.openStream();
|
||||||
outFile = File.createTempFile(libPrefix + "jcpuid", "lib.tmp" + libSuffix);
|
outFile = File.createTempFile(libPrefix + "jcpuid", "lib.tmp" + libSuffix);
|
||||||
FileOutputStream fos = new FileOutputStream(outFile);
|
fos = new FileOutputStream(outFile);
|
||||||
byte buf[] = new byte[4096*1024];
|
byte buf[] = new byte[4096*1024];
|
||||||
while (true) {
|
while (true) {
|
||||||
int read = libStream.read(buf);
|
int read = libStream.read(buf);
|
||||||
@ -494,6 +495,7 @@ public class CPUID {
|
|||||||
fos.write(buf, 0, read);
|
fos.write(buf, 0, read);
|
||||||
}
|
}
|
||||||
fos.close();
|
fos.close();
|
||||||
|
fos = null;
|
||||||
System.load(outFile.getAbsolutePath());//System.load requires an absolute path to the lib
|
System.load(outFile.getAbsolutePath());//System.load requires an absolute path to the lib
|
||||||
return true;
|
return true;
|
||||||
} catch (UnsatisfiedLinkError ule) {
|
} catch (UnsatisfiedLinkError ule) {
|
||||||
@ -510,8 +512,12 @@ public class CPUID {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
if (fos != null) {
|
||||||
|
try { fos.close(); } catch (IOException ioe) {}
|
||||||
|
}
|
||||||
if (outFile != null) {
|
if (outFile != null) {
|
||||||
outFile.deleteOnExit();
|
if (!outFile.delete())
|
||||||
|
outFile.deleteOnExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,10 +482,11 @@ public class NativeBigInteger extends BigInteger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File outFile = null;
|
File outFile = null;
|
||||||
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
InputStream libStream = resource.openStream();
|
InputStream libStream = resource.openStream();
|
||||||
outFile = File.createTempFile(_libPrefix + "jbigi", "lib.tmp" + _libSuffix);
|
outFile = File.createTempFile(_libPrefix + "jbigi", "lib.tmp" + _libSuffix);
|
||||||
FileOutputStream fos = new FileOutputStream(outFile);
|
fos = new FileOutputStream(outFile);
|
||||||
byte buf[] = new byte[4096*1024];
|
byte buf[] = new byte[4096*1024];
|
||||||
while (true) {
|
while (true) {
|
||||||
int read = libStream.read(buf);
|
int read = libStream.read(buf);
|
||||||
@ -493,6 +494,7 @@ public class NativeBigInteger extends BigInteger {
|
|||||||
fos.write(buf, 0, read);
|
fos.write(buf, 0, read);
|
||||||
}
|
}
|
||||||
fos.close();
|
fos.close();
|
||||||
|
fos = null;
|
||||||
System.load(outFile.getAbsolutePath()); //System.load requires an absolute path to the lib
|
System.load(outFile.getAbsolutePath()); //System.load requires an absolute path to the lib
|
||||||
return true;
|
return true;
|
||||||
} catch (UnsatisfiedLinkError ule) {
|
} catch (UnsatisfiedLinkError ule) {
|
||||||
@ -509,8 +511,12 @@ public class NativeBigInteger extends BigInteger {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
if (fos != null) {
|
||||||
|
try { fos.close(); } catch (IOException ioe) {}
|
||||||
|
}
|
||||||
if (outFile != null) {
|
if (outFile != null) {
|
||||||
outFile.deleteOnExit();
|
if (!outFile.delete())
|
||||||
|
outFile.deleteOnExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user