From 40b68ba6c9e49df0079def4bdec6162bfe056683 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 17 Feb 2014 11:48:23 +0000 Subject: [PATCH] * fixed "Can't move across drives on Windows" bug @see http://www.filebot.net/forums/viewtopic.php?f=6&t=1326 --- source/net/sourceforge/tuned/FileUtilities.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/tuned/FileUtilities.java b/source/net/sourceforge/tuned/FileUtilities.java index a35f6551..6bae382a 100644 --- a/source/net/sourceforge/tuned/FileUtilities.java +++ b/source/net/sourceforge/tuned/FileUtilities.java @@ -14,6 +14,7 @@ import java.io.StringWriter; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; +import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Collection; @@ -53,7 +54,11 @@ public final class FileUtilities { // move file try { // * On Windows ATOMIC_MOVE allows us to rename files even if only lower/upper-case changes (without ATOMIC_MOVE the operation would be ignored) - java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); + try { + java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); + } catch (AtomicMoveNotSupportedException e) { + java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING); + } } catch (LinkageError e) { org.apache.commons.io.FileUtils.moveFile(source, destination); // use "copy and delete" as fallback if standard rename fails }