From dbf487b0388bfede5ff5af321f1f6b5290e47188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Thu, 13 Feb 2020 20:20:57 +0100 Subject: [PATCH] Make FileUtils#moveToTrash a varargs method --- CHANGES.md | 7 ++++--- contrib/platform/src/com/sun/jna/platform/FileUtils.java | 6 ++++-- .../src/com/sun/jna/platform/mac/MacFileUtils.java | 2 +- .../src/com/sun/jna/platform/win32/W32FileUtils.java | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f7b8eb8777..dd8809f84d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,14 +2,15 @@ NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and AL 2.0 (see LICENSE NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions. -Next Release (5.5.1) +Next Release (5.6.0) ==================== Features -------- +* [#1160](https://github.com/java-native-access/jna/issues/1160): Make FileUtils#moveToTrash a varargs method - [@matthiasblaesing](https://github.com/matthiasblaesing). -Features --------- +Bug Fixes +--------- Release 5.5.0 diff --git a/contrib/platform/src/com/sun/jna/platform/FileUtils.java b/contrib/platform/src/com/sun/jna/platform/FileUtils.java index 30ac5d81ea..b318bf7c79 100644 --- a/contrib/platform/src/com/sun/jna/platform/FileUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/FileUtils.java @@ -42,7 +42,7 @@ public boolean hasTrash() { * @param files files to move * @throws IOException on failure. */ - public abstract void moveToTrash(File[] files) throws IOException; + public abstract void moveToTrash(File... files) throws IOException; /** Canonical lazy loading of a singleton. */ private static class Holder { @@ -90,6 +90,7 @@ private File getTrashDirectory() { return trash; } + @Override public boolean hasTrash() { return getTrashDirectory().exists(); } @@ -97,7 +98,8 @@ public boolean hasTrash() { /** The default implementation attempts to move the file to * the desktop "Trash" folder. */ - public void moveToTrash(File[] files) throws IOException { + @Override + public void moveToTrash(File... files) throws IOException { File trash = getTrashDirectory(); if (!trash.exists()) { throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)"); diff --git a/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java b/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java index 94207e169c..29cfe7d531 100644 --- a/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java @@ -68,7 +68,7 @@ class FSRef extends Structure { } @Override - public void moveToTrash(File[] files) throws IOException { + public void moveToTrash(File... files) throws IOException { List failed = new ArrayList(); for (File src: files) { FileManager.FSRef fsref = new FileManager.FSRef(); diff --git a/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java b/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java index d11e643d1c..8184b0d00c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java @@ -30,11 +30,13 @@ public class W32FileUtils extends FileUtils { + @Override public boolean hasTrash() { return true; } - public void moveToTrash(File[] files) throws IOException { + @Override + public void moveToTrash(File... files) throws IOException { Shell32 shell = Shell32.INSTANCE; ShellAPI.SHFILEOPSTRUCT fileop = new ShellAPI.SHFILEOPSTRUCT(); fileop.wFunc = ShellAPI.FO_DELETE;