From: Tuukka Lehtonen Date: Sun, 5 Nov 2017 11:53:45 +0000 (+0200) Subject: Use java.file.nio API Files.createDirectories instead of File.mkdirs X-Git-Tag: v1.31.0~57 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=bdbcaeeef059e97bcaba696f129deb1d5c16c0bf;p=simantics%2Fplatform.git Use java.file.nio API Files.createDirectories instead of File.mkdirs This should at least provide better diagnostics in case of unexpected failure. refs #7600 Change-Id: Ib5fb10798257cd35d3d8c3c533574b17a62e715b --- diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java index 1c0b9b841..b303dfc4c 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java @@ -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() {