Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FileUtils#moveToTrash a varargs method #1166

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions contrib/platform/src/com/sun/jna/platform/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -90,14 +90,16 @@ private File getTrashDirectory() {
return trash;
}

@Override
public boolean hasTrash() {
return getTrashDirectory().exists();
}

/** 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)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FSRef extends Structure {
}

@Override
public void moveToTrash(File[] files) throws IOException {
public void moveToTrash(File... files) throws IOException {
List<String> failed = new ArrayList<String>();
for (File src: files) {
FileManager.FSRef fsref = new FileManager.FSRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down