diff --git a/source/net/filebot/NativeRenameAction.java b/source/net/filebot/NativeRenameAction.java index 4c44d0f9..a53490f4 100644 --- a/source/net/filebot/NativeRenameAction.java +++ b/source/net/filebot/NativeRenameAction.java @@ -42,7 +42,8 @@ public enum NativeRenameAction implements RenameAction { private static void SHFileOperation(NativeRenameAction action, String[] src, String[] dst) { // configure parameter structure SHFILEOPSTRUCT op = new SHFILEOPSTRUCT(); - op.wFunc = (action == MOVE) ? ShellAPI.FO_MOVE : ShellAPI.FO_COPY; + + op.wFunc = SHFileOperationFunction(action); op.fFlags = Shell32.FOF_MULTIDESTFILES | Shell32.FOF_NOCOPYSECURITYATTRIBS | Shell32.FOF_NOCONFIRMATION | Shell32.FOF_NOCONFIRMMKDIR; op.pFrom = op.encodePaths(src); @@ -55,6 +56,17 @@ public enum NativeRenameAction implements RenameAction { } } + private static int SHFileOperationFunction(NativeRenameAction action) { + switch (action) { + case MOVE: + return ShellAPI.FO_MOVE; + case COPY: + return ShellAPI.FO_COPY; + default: + throw new UnsupportedOperationException("SHFileOperation not supported: " + action); + } + } + private static String[] getPathArray(List files) { return files.stream().map(File::getAbsolutePath).toArray(String[]::new); }