try to find out temp file errors on maven build
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1746932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56b23028ba
commit
c423015a1b
@ -96,20 +96,24 @@ public final class TempFile {
|
|||||||
public File createTempFile(String prefix, String suffix) throws IOException {
|
public File createTempFile(String prefix, String suffix) throws IOException {
|
||||||
// Identify and create our temp dir, if needed
|
// Identify and create our temp dir, if needed
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
dir = new File(System.getProperty(JAVA_IO_TMPDIR), "poifiles");
|
String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
|
||||||
if(!dir.exists()) {
|
if (tmpDir == null) {
|
||||||
if(!dir.mkdirs()) {
|
throw new IOException("Systems temporary directory not defined - set the -D"+JAVA_IO_TMPDIR+" jvm property!");
|
||||||
throw new IOException("Could not create temporary directory '" + dir + "'");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
dir = new File(tmpDir, "poifiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(dir.exists() || dir.mkdirs()) || !dir.isDirectory()) {
|
||||||
|
throw new IOException("Could not create temporary directory '" + dir + "'");
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a unique new filename
|
// Generate a unique new filename
|
||||||
File newFile = File.createTempFile(prefix, suffix, dir);
|
File newFile = File.createTempFile(prefix, suffix, dir);
|
||||||
|
|
||||||
// Set the delete on exit flag, unless explicitly disabled
|
// Set the delete on exit flag, unless explicitly disabled
|
||||||
if (System.getProperty("poi.keep.tmp.files") == null)
|
if (System.getProperty("poi.keep.tmp.files") == null) {
|
||||||
newFile.deleteOnExit();
|
newFile.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
return newFile;
|
return newFile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user