Search in sources :

Example 51 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class TransferFileJob method tryCopySymlinkFile.

protected boolean tryCopySymlinkFile(AbstractFile sourceFile, AbstractFile destFile) {
    Path sourcePath = ((File) sourceFile.getUnderlyingFileObject()).toPath();
    Path destPath = ((File) destFile.getUnderlyingFileObject()).toPath();
    try {
        Files.createSymbolicLink(destPath, Files.readSymbolicLink(sourcePath));
    } catch (IOException e) {
        LOGGER.debug("failed to create symbolic link " + destFile, e);
        return false;
    }
    // Preserve source file's date
    tryCopyFileDate(sourceFile, destFile);
    // Preserve source file's permissions: preserve only the permissions bits that are supported by the source file
    // and use default permissions for the rest of them.
    tryCopyFilePermissions(sourceFile, destFile);
    // Under Mac OS X only, preserving the file type and creator
    DesktopManager.postCopy(sourceFile, destFile);
    return true;
}
Also used : Path(java.nio.file.Path) IOException(java.io.IOException) File(java.io.File) AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 52 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class ExtensionManager method getDefaultExtensionsFolder.

/**
 * Returns the path to the default extensions folder.
 * <p>
 * The default path is:
 * <pre>
 * {@link PlatformManager#getPreferencesFolder()}.{@link AbstractFile#getChild(String) getChild}({@link #DEFAULT_EXTENSIONS_FOLDER_NAME});
 * </pre>
 * </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;
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 53 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class ExtensionManager method importLibrary.

// - Classpath extension ----------------------------------------------------
// --------------------------------------------------------------------------
/**
 * Imports the specified file in muCommander's libraries.
 * @param file  path to the library to import.
 * @param  force       wether to overwrite eventual existing libraries of the same name.
 * @return             <code>true</code> if the operation was a success,
 *                     <code>false</code> if a library of the same name already exists and
 *                     <code>force</code> is set to <code>false</code>.
 * @throws IOException if an I/O error occurs.
 */
public static boolean importLibrary(AbstractFile file, boolean force) throws IOException {
    AbstractFile dest;
    // there's nothing to do.
    if (isAvailable(file))
        return true;
    // If the destination file already exists, either delete it
    // if force is set to true or just return false.
    dest = getExtensionsFile(file.getName());
    if (dest.exists()) {
        if (!force)
            return false;
        dest.delete();
    }
    // Copies the library and adds it to the extensions classpath.
    file.copyTo(dest);
    addToClassPath(dest);
    return true;
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 54 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class FileJob method run.

// ///////////////////////////
// Runnable implementation //
// ///////////////////////////
/**
 * This method is public as a side-effect of this class implementing <code>Runnable</code>.
 */
public final void run() {
    FileTable activeTable = getMainFrame().getActiveTable();
    // Notify that this job has started
    jobStarted();
    // Loop on all source files, checking that job has not been interrupted
    for (currentFileIndex = 0; currentFileIndex < nbFiles; currentFileIndex++) {
        AbstractFile currentFile = files.elementAt(currentFileIndex);
        // Change current file and advance file index
        nextFile(currentFile);
        // Process current file
        boolean success = processFile(currentFile, null);
        // Stop if job was interrupted
        if (getState() == FileJobState.INTERRUPTED)
            break;
        // and file was processed successfully
        if (autoUnmark && success) {
            // Do not repaint rows individually as it would be too expensive
            activeTable.setFileMarked(currentFile, false, false);
        }
    }
    // without errors, switch to FINISHED state and notify listeners
    if (currentFileIndex == nbFiles && getState() != FileJobState.INTERRUPTED) {
        stop();
        jobCompleted();
        setState(FileJobState.FINISHED);
    }
    // Refresh tables's current folders, based on the job's refresh policy.
    refreshTables();
    JobsManager.getInstance().jobEnded(this);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileTable(com.mucommander.ui.main.table.FileTable)

Example 55 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class ActionKeymapIO method loadActionKeymap.

/**
 * Loads the action files: loads the one contained in the JAR file first, and then the user's one.
 * This means any new action in the JAR action keymap (when a new version is released) will have the default
 * keyboard mapping, but the keyboard mappings customized by the user in the user's action keymap will override
 * the ones from the JAR action keymap.
 *
 * <p>This method must be called before requesting and registering any action.
 */
public static void loadActionKeymap() throws Exception {
    // Load user's file if exist
    AbstractFile actionKeymapFile = getActionsFile();
    if (actionKeymapFile != null && actionKeymapFile.exists()) {
        ActionKeymapReader reader = new ActionKeymapReader(actionKeymapFile);
        ActionKeymap.registerActions(reader.getPrimaryActionsKeymap(), reader.getAlternateActionsKeymap());
    } else {
        createEmptyFile();
        LOGGER.debug(DEFAULT_ACTIONS_FILE_NAME + " was not found, created empty file");
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)150 IOException (java.io.IOException)49 FileURL (com.mucommander.commons.file.FileURL)19 FileSet (com.mucommander.commons.file.util.FileSet)11 FileTable (com.mucommander.ui.main.table.FileTable)11 DialogAction (com.mucommander.ui.dialog.DialogAction)10 File (java.io.File)9 List (java.util.List)8 MainFrame (com.mucommander.ui.main.MainFrame)6 InputStream (java.io.InputStream)6 Vector (java.util.Vector)6 AbstractArchiveEntryFile (com.mucommander.commons.file.archive.AbstractArchiveEntryFile)5 ProtocolFile (com.mucommander.commons.file.protocol.ProtocolFile)5 LocalFile (com.mucommander.commons.file.protocol.local.LocalFile)5 ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)5 FolderPanel (com.mucommander.ui.main.FolderPanel)5 FileTableModel (com.mucommander.ui.main.table.FileTableModel)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 UnsupportedFileOperationException (com.mucommander.commons.file.UnsupportedFileOperationException)4