X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.fmil.core%2Fsrc%2Forg%2Fsimantics%2Ffmil%2Fcore%2FFMIL.java;h=f4c7ca4f2fbbf7d044be10c09a2b4f896b31fe0b;hb=refs%2Fchanges%2F63%2F2163%2F2;hp=7301caf4c8209883e9d77aaaa3fc3e5bc6a5aa17;hpb=7cdd9e0931c9905bde72e01038d16589a3040ee6;p=simantics%2Ffmil.git diff --git a/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java b/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java index 7301caf..f4c7ca4 100644 --- a/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java +++ b/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java @@ -6,6 +6,7 @@ import java.io.RandomAccessFile; import java.net.URL; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; +import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; @@ -193,21 +194,23 @@ public class FMIL { fmuN = 0; } - File tempDir = new File(fmuDir); - if(tempDir.isDirectory()) { + java.nio.file.Path tempDir = Paths.get(fmuDir); + if(Files.exists(tempDir) && Files.isDirectory(tempDir)) { try { - FileUtils.deleteAll(tempDir); + FileUtils.emptyDirectory(tempDir); } catch (IOException e) { - throw new FMILException("Could not create temp folder for fmu"); + throw new FMILException("Could not delete existing files from temp folder for fmu " + path, e); } - tempDir.mkdir(); } else { - tempDir.mkdir(); + try { + Files.createDirectory(tempDir); + } catch (IOException e) { + throw new FMILException("Could not create temp folder for fmu " + path, e); + } } - try { - String tmpPath = tempDir.getAbsolutePath(); + String tmpPath = tempDir.toString(); if(!tmpPath.endsWith("\\") && !tmpPath.endsWith("/")) tmpPath = tmpPath + "/"; id = loadFMUFile_(path, tmpPath);