X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils%2Fsrc%2Forg%2Fsimantics%2Futils%2FFileUtils.java;h=798fd02b8742c302958c495759fc2ef7950c5b0c;hb=34656219dde2130ecbeedd274ddd83c6df5699e0;hp=b794c9360473a360d973ba5826a3d96eef942a62;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java b/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java index b794c9360..798fd02b8 100644 --- a/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java +++ b/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java @@ -492,7 +492,7 @@ public class FileUtils { } } } else if (dir.exists()) { - if (filter.contains(dir.getAbsolutePath())) { + if (!filter.contains(dir.getAbsolutePath())) { if (!dir.delete()) { throw new IOException("Could not delete file: " + dir.getAbsolutePath()); } @@ -840,8 +840,8 @@ public class FileUtils { * @throws IOException */ public static void extractZip(File zipFile, File dst) throws IOException { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Extracting zip "+zipFile); + if (LOGGER.isTraceEnabled()) + LOGGER.trace("Extracting zip "+zipFile); try (FileInputStream fis = new FileInputStream(zipFile)) { extractZip(fis, dst); } @@ -863,8 +863,8 @@ public class FileUtils { while (entry != null) { // for each entry to be extracted String name = entry.getName(); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Extracting "+name); + if (LOGGER.isTraceEnabled()) + LOGGER.trace("Extracting "+name); File file = new File(dst, name); if (entry.isDirectory()) @@ -1013,4 +1013,10 @@ public class FileUtils { return FileVisitResult.CONTINUE; } } + + public static void syncFile(File file) throws IOException { + try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) { + raf.getFD().sync(); + } + } }