@Override public OutputStream getOutputStream() throws IOException { return file.getOutputStream(); }
/** * Implementation of {@link com.mucommander.desktop.QueuedTrash} moveToTrash method. * * <p>Try to copy a collection of files to the Xfce's Trash. * * @param queuedFiles Collection of files to the trash * @return <code>true</code> if movement has been successful or <code>false</code> otherwise */ @Override protected boolean moveToTrash(List<AbstractFile> queuedFiles) { boolean retVal = true; // overall return value (if everything went OK or at least one file wasn't moved // properly for (AbstractFile fileToDelete : queuedFiles) { String fileInfoContent; String trashFileName; // generate content of info file and new filename try { fileInfoContent = getFileInfoContent(fileToDelete); trashFileName = getUniqueFilename(fileToDelete); } catch (IOException ex) { LOGGER.debug("Failed to create filename for new trash item: " + fileToDelete.getName(), ex); // continue with other file (do not move file, because info file cannot be properly created continue; } AbstractFile infoFile = null; OutputStreamWriter infoWriter = null; try { // create info file infoFile = TRASH_INFO_SUBFOLDER.getChild(trashFileName + ".trashinfo"); infoWriter = new OutputStreamWriter(infoFile.getOutputStream()); infoWriter.write(fileInfoContent); } catch (IOException ex) { retVal = false; LOGGER.debug("Failed to create trash info file: " + trashFileName, ex); // continue with other file (do not move file, because info file wasn't properly created) continue; } finally { if (infoWriter != null) { try { infoWriter.close(); } catch (IOException e) { // Not much else to do } } } try { // rename original file fileToDelete.renameTo(TRASH_FILES_SUBFOLDER.getChild(trashFileName)); } catch (IOException ex) { try { // remove info file infoFile.delete(); } catch (IOException ex1) { // simply ignore } retVal = false; LOGGER.debug("Failed to move file to trash: " + trashFileName, ex); } } return retVal; }