Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.AbstractFile


            if(random.nextInt(2)==0)
                ActionManager.performAction(com.mucommander.ui.action.impl.SwitchActiveTableAction.Descriptor.ACTION_ID, mainFrame);   

            FolderPanel folderPanel = mainFrame.getActivePanel();
            FileTable fileTable = mainFrame.getActiveTable();
            AbstractFile currentFolder = folderPanel.getCurrentFolder();

            try {
                AbstractFile parentFolder = currentFolder.getParent();
                AbstractFile children[] = currentFolder.ls();
                // 1 in 3 chance to go up if folder has children
                if(children.length==0 || (random.nextInt(3)==0 && parentFolder!=null)) {
                    fileTable.selectRow(0);
                    ActionManager.performAction(com.mucommander.ui.action.impl.OpenAction.Descriptor.ACTION_ID, mainFrame);
                }
                else {
                    AbstractFile randomChild = children[random.nextInt(children.length)];
                    if(!randomChild.isBrowsable())
                        continue;
                    // Try to ls() in RandomChild to trigger an IOException if folder is not readable
                    // so that no error dialog pops up when calling tryChangeCurrentFolder()
                    randomChild.ls();
                    fileTable.selectFile(randomChild);
                    ActionManager.performAction(com.mucommander.ui.action.impl.OpenAction.Descriptor.ACTION_ID, mainFrame);
                    //          folderPanel.tryChangeCurrentFolder(randomChild, true);
                }
            }
View Full Code Here


        // application is launched with a file to open, for instance when drag-n-dropping a file to the Dock icon
        // when muCommander is not started yet. In this case, this method is called while Launcher is still busy
        // launching the application (no mainframe exists yet).
        Launcher.waitUntilLaunched();

        AbstractFile file = FileFactory.getFile(event.getFilename());
        FolderPanel activePanel = WindowManager.getCurrentMainFrame().getActivePanel();
        if(file.isBrowsable())
            activePanel.tryChangeCurrentFolder(file);
        else
            activePanel.tryChangeCurrentFolder(file.getParent(), file, false);
    }
View Full Code Here

            return destJar;
        }
    }

    private static AbstractFile createTemporaryFolder() {
        AbstractFile tempFolder;
        try {
            tempFolder = FileFactory.getTemporaryFile("mucomander-self-update", true);
            tempFolder.mkdir();
        }
        catch(IOException e) {
            tempFolder = FileFactory.getTemporaryFolder();
        }
View Full Code Here

    }

    @Override
    protected void jobCompleted() {
        try {
            AbstractFile parent;
            // Mac OS X
            if(OsFamily.MAC_OS_X.isCurrent()) {
                parent = destJar.getParent();

                // Look for an .app container that encloses the JAR file
                if(parent.getName().equals("Java")
                &&(parent=parent.getParent())!=null && parent.getName().equals("Resources")
                &&(parent=parent.getParent())!=null && parent.getName().equals("Contents")
                &&(parent=parent.getParent())!=null && "app".equals(parent.getExtension())) {

                    String appPath = parent.getAbsolutePath();

                    LOGGER.debug("Opening "+appPath);

                    // Open -W wait for the current muCommander .app to terminate, before re-opening it
                    ProcessRunner.execute(new String[]{"/bin/sh", "-c", "open -W "+appPath+" && open "+appPath});

                    return;
                }
            }
            else {
                parent = destJar.getParent();
                EqualsFilenameFilter launcherFilter;

                // Windows
                if(OsFamily.WINDOWS.isCurrent()) {
                    // Look for a muCommander.exe launcher located in the same folder as the JAR file
                    launcherFilter = new EqualsFilenameFilter("muCommander.exe", false);

                }
                // Other platforms, possibly Unix/Linux
                else {
                    // Look for a mucommander.sh located in the same folder as the JAR file
                    launcherFilter = new EqualsFilenameFilter("mucommander.sh", false);
                }

                AbstractFile[] launcherFile = parent.ls(launcherFilter);

                // If a launcher file was found, execute it
                if(launcherFile!=null && launcherFile.length==1) {
                    DesktopManager.open(launcherFile[0]);
View Full Code Here

        // change the FolderPanel's current folder to the dropped file/folder :
        // - If the file is a directory, the current folder is changed to that directory
        // - For any other file kind (archive, regular file...), current folder is changed to the file's parent folder and the file is selected
        // If more than one file is dropped, only the first one is used
        if(changeFolderOnlyMode || currentDropAction==DnDConstants.ACTION_LINK) {
            AbstractFile file = droppedFiles.elementAt(0);

            // If file is a directory, change current folder to that directory
            if(file.isDirectory())
                folderPanel.tryChangeCurrentFolder(file);
            // For any other file kind (archive, regular file...), change directory to the file's parent folder
            // and select the file
            else
                folderPanel.tryChangeCurrentFolder(file.getParent(), file, false);

            // Request focus on the FolderPanel
            folderPanel.requestFocus();
        }
        // Normal mode: copy or move dropped files to the FolderPanel's current folder
        else {
            MainFrame mainFrame = folderPanel.getMainFrame();
            AbstractFile destFolder = folderPanel.getCurrentFolder();
            if(currentDropAction==DnDConstants.ACTION_MOVE) {
                // Start moving files
                ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("move_dialog.moving"));
                MoveJob moveJob = new MoveJob(progressDialog, mainFrame, droppedFiles, destFolder, null, FileCollisionDialog.ASK_ACTION, false);
                progressDialog.start(moveJob);
View Full Code Here

    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
   
      Thread setLocationThread = new Thread() {
        @Override
        public void run() {
          AbstractFile folder = getWorkableLocation(folderURL);
          try {
            locationManager.setCurrentFolder(folder, null, true);
          } finally {
            mainFrame.setNoEventsMode(false);
            // Restore default cursor
View Full Code Here

   * - if the given folder is local file, find workable location
   *   according to the logic used for inaccessible local files
   * - Otherwise, return the non-exist remote location
   */
  private AbstractFile getWorkableLocation(FileURL folderURL) {
    AbstractFile folder = FileFactory.getFile(folderURL);
    if (folder != null && folder.exists())
      return folder;
   
    if (folder == null)
      folder = new NullableFile(folderURL);
   
View Full Code Here

                if (file.isDirectory() && !file.isSymlink()) {
                    // Create new directory entry in archive file
                    archiver.createEntry(entryRelativePath, file);

                    // Recurse on files
                    AbstractFile subFiles[] = file.ls();
                    boolean folderComplete = true;
                    for(int i=0; i<subFiles.length && getState()!=INTERRUPTED; i++) {
                        // Notify job that we're starting to process this file (needed for recursive calls to processFile)
                        nextFile(subFiles[i]);
                        if(!processFile(subFiles[i], null))
View Full Code Here

   * @param folder folder for which to find a workable folder
   * @return a 'workable' folder for the given non-existing folder, <code>null</code> if there is none.
   */
  private AbstractFile getWorkableFolder(AbstractFile folder) {
    // Look for an existing parent
    AbstractFile newFolder = folder;
    do {
      newFolder = newFolder.getParent();
      if(newFolder!=null && newFolder.exists())
        return newFolder;
    }
    while(newFolder!=null);

    // Fall back to the first existing volume
View Full Code Here

  /**
   * Checks if CRC file exists.
   * @param file firts part
   */
  private void findCRCFile(AbstractFile file) {
    AbstractFile f = file.getParent();
    if (f != null) {
      try {
        crcFile = f.getDirectChild(file.getNameWithoutExtension() + ".sfv");
      } catch (IOException e) {
        LOGGER.debug("Caught exception", e);
      }
    }
  }
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.