From 6499e074f911adb6d109ae7a048e2b313a83348f Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 28 Aug 2014 19:23:28 +0000 Subject: [PATCH] * resolve relative files properly when asking for folder permissions --- source/net/filebot/ui/rename/RenameAction.java | 2 +- source/net/filebot/util/FileUtilities.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/ui/rename/RenameAction.java b/source/net/filebot/ui/rename/RenameAction.java index 22ea7bad..f3c2c8d7 100644 --- a/source/net/filebot/ui/rename/RenameAction.java +++ b/source/net/filebot/ui/rename/RenameAction.java @@ -155,7 +155,7 @@ class RenameAction extends AbstractAction { private Map checkRenamePlan(List> renamePlan, Window parent) throws IOException { // ask for user permissions to output paths if (isMacSandbox()) { - if (!DropToUnlock.showUnlockFoldersDialog(parent, renamePlan.stream().flatMap(e -> Stream.of(e.getValue(), e.getKey())).map(f -> new File(f.getAbsolutePath())).collect(Collectors.toList()))) { + if (!DropToUnlock.showUnlockFoldersDialog(parent, renamePlan.stream().flatMap(e -> Stream.of(e.getKey(), resolveDestination(e.getKey(), e.getValue()))).map(f -> new File(f.getAbsolutePath())).collect(Collectors.toList()))) { return emptyMap(); } } diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index dd1d533c..6b7b88eb 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -94,6 +94,16 @@ public final class FileUtilities { return Files.copy(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING).toFile(); } + public static File resolveDestination(File source, File destination) { + // resolve destination + if (!destination.isAbsolute()) { + // same folder, different name + destination = new File(source.getParentFile(), destination.getPath()); + } + + return destination; + } + public static File resolveDestination(File source, File destination, boolean mkdirs) throws IOException { // resolve destination if (!destination.isAbsolute()) {