summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-06-05 16:49:18 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-06-05 16:49:18 +0000
commit0c86338a8f79b157ebd98dac5357baa2da7ddc16 (patch)
tree845f956421e76c5ca1727b32c4430b1439d647ea /src/java
parenta3baac75a358552af301e6d34b816ef6868b0174 (diff)
downloadpoi-0c86338a8f79b157ebd98dac5357baa2da7ddc16.tar.gz
poi-0c86338a8f79b157ebd98dac5357baa2da7ddc16.zip
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
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/util/TempFile.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/util/TempFile.java b/src/java/org/apache/poi/util/TempFile.java
index b228d237d1..44f461379c 100644
--- a/src/java/org/apache/poi/util/TempFile.java
+++ b/src/java/org/apache/poi/util/TempFile.java
@@ -96,20 +96,24 @@ public final class TempFile {
public File createTempFile(String prefix, String suffix) throws IOException {
// Identify and create our temp dir, if needed
if (dir == null) {
- dir = new File(System.getProperty(JAVA_IO_TMPDIR), "poifiles");
- if(!dir.exists()) {
- if(!dir.mkdirs()) {
- throw new IOException("Could not create temporary directory '" + dir + "'");
- }
+ String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
+ if (tmpDir == null) {
+ throw new IOException("Systems temporary directory not defined - set the -D"+JAVA_IO_TMPDIR+" jvm property!");
}
+ 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
File newFile = File.createTempFile(prefix, suffix, dir);
// 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();
+ }
// All done
return newFile;