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;
}
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;
}
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;
}
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);
}
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");
}
}
Aggregations