1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* resolve relative files properly when asking for folder permissions

This commit is contained in:
Reinhard Pointner 2014-08-28 19:23:28 +00:00
parent c6099ddb58
commit 6499e074f9
2 changed files with 11 additions and 1 deletions

View File

@ -155,7 +155,7 @@ class RenameAction extends AbstractAction {
private Map<File, File> checkRenamePlan(List<Entry<File, File>> 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();
}
}

View File

@ -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()) {