IO-280 Dubious use of mkdirs() return code

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1163210 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d6eb48a..75b9967 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -41,6 +41,9 @@
   <body>
     <release version="1.4" date="Not yet released">
 
+      <action dev="sebb" type="fix" issue="IO-280" due-to="sebb">
+        Dubious use of mkdirs() return code
+      </action>
       <action dev="sebb" type="fix" issue="IO-274" due-to="Frank Grimes">
         Tailer returning partial lines when reaching EOF before EOL
       </action>
diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 4dff56b..35e423d 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -324,9 +324,9 @@
             }
         } else {
             File parent = file.getParentFile();
-            if (parent != null && parent.exists() == false) {
-                if (parent.mkdirs() == false) {
-                    throw new IOException("File '" + file + "' could not be created");
+            if (parent != null) {
+                if (!parent.mkdirs() && !parent.isDirectory()) {
+                    throw new IOException("Directory '" + parent + "' could not be created");
                 }
             }
         }
@@ -876,9 +876,10 @@
         if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) {
             throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same");
         }
-        if (destFile.getParentFile() != null && destFile.getParentFile().exists() == false) {
-            if (destFile.getParentFile().mkdirs() == false) {
-                throw new IOException("Destination '" + destFile + "' directory cannot be created");
+        File parentFile = destFile.getParentFile();
+        if (parentFile != null) {
+            if (!parentFile.mkdirs() && !parentFile.isDirectory()) {
+                throw new IOException("Destination '" + parentFile + "' directory cannot be created");
             }
         }
         if (destFile.exists() && destFile.canWrite() == false) {
@@ -1182,7 +1183,7 @@
                 throw new IOException("Destination '" + destDir + "' exists but is not a directory");
             }
         } else {
-            if (destDir.mkdirs() == false) {
+            if (!destDir.mkdirs() && !destDir.isDirectory()) {
                 throw new IOException("Destination '" + destDir + "' directory cannot be created");
             }
         }