private static class W32FileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public void moveToTrash(File[] files) throws IOException {
Shell32 shell = Shell32.INSTANCE;
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
fileop.wFunc = Shell32.FO_DELETE;
String[] paths = new String[files.length];
for (int i=0;i < paths.length;i++) {
paths[i] = files[i].getAbsolutePath();
}
fileop.pFrom = fileop.encodePaths(paths);
fileop.fFlags = Shell32.FOF_ALLOWUNDO|Shell32.FOF_NOCONFIRMATION|Shell32.FOF_SILENT;
int ret = shell.SHFileOperation(fileop);
if (ret != 0) {
throw new IOException("Move to trash failed: " + ret);
}
if (fileop.fAnyOperationsAborted) {
throw new IOException("Move to trash aborted");