Refactor NativeRenameAction
This commit is contained in:
parent
0fd06eff35
commit
8ac28f25e4
|
@ -42,7 +42,8 @@ public enum NativeRenameAction implements RenameAction {
|
||||||
private static void SHFileOperation(NativeRenameAction action, String[] src, String[] dst) {
|
private static void SHFileOperation(NativeRenameAction action, String[] src, String[] dst) {
|
||||||
// configure parameter structure
|
// configure parameter structure
|
||||||
SHFILEOPSTRUCT op = new SHFILEOPSTRUCT();
|
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.fFlags = Shell32.FOF_MULTIDESTFILES | Shell32.FOF_NOCOPYSECURITYATTRIBS | Shell32.FOF_NOCONFIRMATION | Shell32.FOF_NOCONFIRMMKDIR;
|
||||||
|
|
||||||
op.pFrom = op.encodePaths(src);
|
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<File> files) {
|
private static String[] getPathArray(List<File> files) {
|
||||||
return files.stream().map(File::getAbsolutePath).toArray(String[]::new);
|
return files.stream().map(File::getAbsolutePath).toArray(String[]::new);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue