Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.AbstractFile


        fieldText = mainFrame.getInactivePanel().getCurrentFolder().getAbsolutePath(true);
        // Append filename to destination path if there is only one file to copy
        // and if the file is not a directory that already exists in destination
        // (otherwise folder would be copied into the destination folder)
        if(nbFiles==1) {
            AbstractFile file = files.elementAt(0);
            AbstractFile destFile;

            startPosition  = fieldText.length();

            if(!(file.isDirectory() && (destFile= FileFactory.getFile(fieldText+file.getName()))!=null && destFile.exists() && destFile.isDirectory())) {
                return selectDestinationFilename(file, fieldText + file.getName(), startPosition);
            }
            else
                endPosition = fieldText.length();
        }
View Full Code Here


        if(clipboardFiles==null || clipboardFiles.isEmpty())
            return;

        // Start copying files
        ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
        AbstractFile destFolder = mainFrame.getActivePanel().getCurrentFolder();
        CopyJob job = new CopyJob(progressDialog, mainFrame, clipboardFiles, destFolder, null, CopyJob.COPY_MODE, FileCollisionDialog.ASK_ACTION);
        progressDialog.start(job);
    }
View Full Code Here

          for (int i=0; i<nbFolderPaths;++i)
            folderPaths[i] = snapshot.getVariable(MuSnapshot.getTabLocationVariable(window, folderPanelType == FolderPanelType.LEFT, i));
        }

        List<AbstractFile> initialFolders = new LinkedList<AbstractFile>(); // Initial folders
        AbstractFile folder;
       
        for (String folderPath : folderPaths) {
          // TODO: consider whether to search for workable path in case the folder doesn't exist
          if (folderPath != null && (folder = FileFactory.getFile(folderPath)) != null && folder.exists())
            initialFolders.add(folder);
        }
       
        // If the initial path is not legal or does not exist, defaults to the user's home.
        AbstractFile[] results = initialFolders.size() == 0 ?
View Full Code Here

          customPath = (folderPanelType == FolderPanelType.LEFT ?
              preferences.getVariable(MuPreference.LEFT_CUSTOM_FOLDER)
              : preferences.getVariable(MuPreference.RIGHT_CUSTOM_FOLDER));
        }

        AbstractFile result = null;
        if (customPath == null || (result = FileFactory.getFile(customPath)) == null || !result.exists())
          result = getHomeFolder();
       
        LOGGER.debug("initial folder: " + result);
       
        return result.getURL();
    }
View Full Code Here

        int nbFilesLeft = leftTableModel.getFileCount();
        int nbFilesRight = rightTableModel.getFileCount();
        int fileIndex;
        String tempFileName;
        AbstractFile tempFile;
        for(int i=0; i<nbFilesLeft; i++) {
            tempFile = leftTableModel.getFileAt(i);
            if(tempFile.isDirectory())
                continue;

            tempFileName = tempFile.getName();
            fileIndex = -1;
            for(int j=0; j<nbFilesRight; j++)
                if (rightTableModel.getFileAt(j).getName().equals(tempFileName)) {
                    fileIndex = j;
                    break;
                }
            if (fileIndex==-1 || rightTableModel.getFileAt(fileIndex).getDate()<tempFile.getDate()) {
                leftTableModel.setFileMarked(tempFile, true);
                leftTable.repaint();
            }
        }

        for(int i=0; i<nbFilesRight; i++) {
            tempFile = rightTableModel.getFileAt(i);
            if(tempFile.isDirectory())
                continue;

            tempFileName = tempFile.getName();
            fileIndex = -1;
            for(int j=0; j<nbFilesLeft; j++)
                if (leftTableModel.getFileAt(j).getName().equals(tempFileName)) {
                    fileIndex = j;
                    break;
                }
            if (fileIndex==-1 || leftTableModel.getFileAt(fileIndex).getDate()<tempFile.getDate()) {
                rightTableModel.setFileMarked(tempFile, true);
                rightTable.repaint();
            }
        }
View Full Code Here

     * @param     file        file on which to open an input stream.
     * @return                a stream on the right file.
     * @exception IOException thrown if any IO related error occurs.
     */
    private static InputStream getInputStream(AbstractFile file) throws IOException {
        AbstractFile backup;
        FileURL test;

        test = (FileURL)file.getURL().clone();
        test.setPath(test.getPath() + BACKUP_SUFFIX);

        // Checks whether the backup file is a better choice than the target one.
        backup = FileFactory.getFile(test);
        if(backup != null && backup.exists() && (file.getSize() < backup.getSize()))
            return backup.getInputStream();

        // Opens a stream on the target file.
        return file.getInputStream();
    }
View Full Code Here

     * Returns the specified file's parent, or an empty string if it doesn't have one.
     * @param  file file whose parent should be returned.
     * @return      the specified file's parent, or an empty string if it doesn't have one.
     */
    private String getParent(AbstractFile file) {
        AbstractFile parent;

        if((parent = file.getParent()) == null)
            return "";
        return parent.getAbsolutePath();
    }
View Full Code Here

     * @see                             #getHistoryFile()
     * @see                             #setHistoryFile(File)
     * @see                             #setHistoryFile(AbstractFile)
     */
    public static void setHistoryFile(String path) throws FileNotFoundException {
        AbstractFile file;

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

     * @see                #setExtensionsFolder(File)
     * @see                #setExtensionsFolder(String)
     * @see                #getExtensionsFolder()
     */
    public static void setExtensionsFolder(String path) throws IOException {
        AbstractFile folder;

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

     * </p>
     * @return             the path to the default extensions folder.
     * @throws IOException if there was an error retrieving the default extensions folder.
     */
    private static AbstractFile getDefaultExtensionsFolder() throws IOException {
        AbstractFile folder;

        folder = PlatformManager.getPreferencesFolder().getChild(DEFAULT_EXTENSIONS_FOLDER_NAME);

        // Makes sure the folder exists.
        if(!folder.exists())
            folder.mkdir();

        return folder;
    }
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.