return AppleScript.execute(appleScript, null);
}
// Script for AppleScript versions without Unicode support (AppleScript 1.10 / Mac OS X 10.4 or lower)
else {
AbstractFile tmpFile = null;
OutputStreamWriter tmpOut = null;
try {
// Create the temporary file that contains the list of files to move, encoded as UTF-8 and separated by
// EOL characters. The file must NOT end with a trailing EOL.
int nbFiles = queuedFiles.size();
tmpFile = FileFactory.getTemporaryFile("trash_files.muco", false);
tmpOut = new OutputStreamWriter(tmpFile.getOutputStream(), "utf-8");
for(int i=0; i<nbFiles; i++) {
tmpOut.write(queuedFiles.get(i).getAbsolutePath());
if(i<nbFiles-1)
tmpOut.write("\n");
}
tmpOut.close();
// Set the 'tmpFilePath' variable to the path of the temporary file we just created
appleScript = "set tmpFilePath to \""+tmpFile.getAbsolutePath()+"\"\n";
appleScript += MOVE_TO_TRASH_APPLESCRIPT_NO_UNICODE;
boolean success = AppleScript.execute(appleScript, null);
// AppleScript has been executed, we can now safely close and delete the temporary file
tmpFile.delete();
return success;
}
catch(IOException e) {
LOGGER.debug("Caught IOException", e);
if(tmpOut!=null) {
try { tmpOut.close(); }
catch(IOException e1) {
// There's not much we can do about it
}
}
if(tmpFile!=null) {
try { tmpFile.delete(); }
catch(IOException e2) {
// There's not much we can do about it
}
}