]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Use java.file.nio API Files.createDirectories instead of File.mkdirs 96/1196/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sun, 5 Nov 2017 11:53:45 +0000 (13:53 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sun, 5 Nov 2017 11:53:45 +0000 (13:53 +0200)
This should at least provide better diagnostics in case of unexpected
failure.

refs #7600

Change-Id: Ib5fb10798257cd35d3d8c3c533574b17a62e715b

bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java

index 1c0b9b8416769db88afadb86d5350a62e98d0606..b303dfc4c4b1fc73f2b10eba9363cab20ddabfb0 100644 (file)
@@ -14,6 +14,8 @@ package org.simantics.db.indexing;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -981,13 +983,10 @@ abstract public class IndexedRelationsSearcherBase {
     }
 
     private static void createDirectory(File path) throws IOException {
-        if (path.exists() && !path.isDirectory())
-            throw new IOException("Could not create index directory " + path + ", a file by that name already exists");
-        path.mkdirs();
-        if (!path.exists())
-            throw new IOException("Could not create index directory " + path + " for an unknown reason");
-        if (!path.isDirectory())
+        Path p = path.toPath();
+        if (Files.exists(p) && !Files.isDirectory(p))
             throw new IOException("Could not create index directory " + path + ", a file by that name already exists");
+        Files.createDirectories(p);
     }
 
     File getIndexPath() {