Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.AbstractFile


            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
                    }
                }
View Full Code Here


        /**
         * Renames the currently edited name cell, only if the filename has changed.
         */
        private void rename() {
            String newName = filenameField.getText();
            AbstractFile fileToRename = tableModel.getFileAtRow(editingRow);

            if(!newName.equals(fileToRename.getName())) {
                AbstractFile current;

                current = folderPanel.getCurrentFolder();
                // Starts moving files
                ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("move_dialog.moving"));
                FileSet files = new FileSet(current);
View Full Code Here

         */
        public void notifyEditingRow(int row) {
            // The editing row has to be saved as it could change after row editing has been started
            this.editingRow = row;

            AbstractFile file = tableModel.getFileAtRow(editingRow);
            AbstractCopyDialog.selectDestinationFilename(file, file.getName(), 0).feedToPathField(filenameField);

            // Request focus on text field
            filenameField.requestFocus();
        }
View Full Code Here

   * Trash folder was found, creates the standard Xfce user Trash folder and returns it.
   *
   * @return the user Trash folder, <code>null</code> if no user trash folder could be found or created
   */
  private static AbstractFile getTrashFolder() {
    AbstractFile userHome = LocalFile.getUserHome();

    AbstractFile trashDir = userHome.getChildSilently(".local/share/Trash/");
    if(isTrashFolder(trashDir)) {
      return trashDir;
    }

    // No existing user trash was found: create the folder, only if it doesn't already exist.
    if(!trashDir.exists()) {
      try {
        trashDir.mkdirs();
        trashDir.getChild("info").mkdir();
        trashDir.getChild("files").mkdir();

        return trashDir;
      }
      catch(IOException e) {
        // Will return null
View Full Code Here

        String fileInfoContent;
        String trashFileName;
        boolean retVal = true;     // overall return value (if everything went OK or at least one file wasn't moved properly
       
        for(int i=0; i<nbFiles; i++) {
            AbstractFile fileToDelete = queuedFiles.get(i);
            // 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
                }
               
View Full Code Here

        Column                column;
        int                   colorIndex;
        int                   focusedIndex;
        int                   selectedIndex;
        CellLabel             label;
        AbstractFile          file;
        boolean               matches;
        QuickSearch       search;

        // Need to check that row index is not out of bounds because when the folder
        // has just been changed, the JTable may try to repaint the old folder and
View Full Code Here

     * @return        <code>true</code> if the operation is supported for the specified parameters, <code>false</code> otherwise.
     * @see           #canExecute(AbstractFile)
     * @see           #extractTarget(Object[])
     */
    public boolean canExecute(Object[] target) {
        AbstractFile file;

        if((file = extractTarget(target)) != null)
            return canExecute(file);
        return false;
    }
View Full Code Here

     * @throws UnsupportedOperationException if the operation is not supported.
     * @see                                  #execute(AbstractFile)
     * @see                                  #extractTarget(Object[])
     */
    public void execute(Object[] target) throws IOException, UnsupportedOperationException {
        AbstractFile file;

        // Makes sure we received the right kind of parameters.
        if((file = extractTarget(target)) == null)
            throw new UnsupportedOperationException();

View Full Code Here

    @Override
    public void performAction() {
        // Changes the current folder to make it the current folder's root folder.
        // Does nothing if the current folder already is the root.
        FolderPanel folderPanel = mainFrame.getActivePanel();
        AbstractFile currentFolder = folderPanel.getCurrentFolder();
        folderPanel.tryChangeCurrentFolder(currentFolder.getRoot());
    }
View Full Code Here

     * @param     path                  path to the bookmarks file
     * @exception FileNotFoundException if <code>path</code> is not accessible.
     * @see       #getBookmarksFile()
     */
    public static void setBookmarksFile(String path) throws FileNotFoundException {
        AbstractFile file;

        if((file = FileFactory.getFile(path)) == null)
            setBookmarksFile(new File(path));
        else
            setBookmarksFile(file);
View Full Code Here

TOP

Related Classes of com.mucommander.commons.file.AbstractFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.