diff options
author | Javen O'Neal <onealj@apache.org> | 2016-09-21 03:19:31 +0000 |
---|---|---|
committer | Javen O'Neal <onealj@apache.org> | 2016-09-21 03:19:31 +0000 |
commit | 5b9c30414809d5faa2cc2b8d1c0c49c750c98060 (patch) | |
tree | 42340c5a0dd2b8a5bfbd5b74d2f81126dfc8404c | |
parent | af39a0654498addf3736fa06dde35f6b1810fca3 (diff) | |
download | poi-5b9c30414809d5faa2cc2b8d1c0c49c750c98060.tar.gz poi-5b9c30414809d5faa2cc2b8d1c0c49c750c98060.zip |
bug 57200,59788: be more specific why a temporary directory could not be created
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1761667 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java b/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java index ef9e8443a4..6f44752873 100644 --- a/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java +++ b/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java @@ -83,15 +83,22 @@ public class DefaultTempFileCreationStrategy implements TempFileCreationStrategy } /** - * Attempt to create a directory + * Attempt to create a directory, including any necessary parent directories. + * Does nothing if directory already exists. * - * @param directory - * @throws IOException + * @param directory the directory to create + * @throws IOException if unable to create temporary directory or it is not a directory */ private void createTempDirectory(File directory) throws IOException { - if (!(directory.exists() || directory.mkdirs()) || !directory.isDirectory()) { + // create directory if it doesn't exist + final boolean dirExists = (directory.exists() || directory.mkdirs()); + + if (!dirExists) { throw new IOException("Could not create temporary directory '" + directory + "'"); } + else if (!directory.isDirectory()) { + throw new IOException("Could not create temporary directory. '" + directory + "' exists but is not a directory."); + } } @Override |