private static void configureFilesystems() { // Configure the SMB subsystem (backed by jCIFS) to maintain compatibility with SMB servers that // don't support // NTLM v2 authentication such as Samba 3.0.x, which still is widely used and comes // pre-installed on // Mac OS X Leopard. // Since jCIFS 1.3.0, the default is to use NTLM v2 authentication and extended security. SMBProtocolProvider.setLmCompatibility( MuConfigurations.getPreferences() .getVariable( MuPreference.SMB_LM_COMPATIBILITY, MuPreferences.DEFAULT_SMB_LM_COMPATIBILITY)); SMBProtocolProvider.setExtendedSecurity( MuConfigurations.getPreferences() .getVariable( MuPreference.SMB_USE_EXTENDED_SECURITY, MuPreferences.DEFAULT_SMB_USE_EXTENDED_SECURITY)); // Use the FTP configuration option that controls whether to force the display of hidden files, // or leave it for // the servers to decide whether to show them. FTPProtocolProvider.setForceHiddenFilesListing( MuConfigurations.getPreferences() .getVariable(MuPreference.LIST_HIDDEN_FILES, MuPreferences.DEFAULT_LIST_HIDDEN_FILES)); // Use CredentialsManager for file URL authentication FileFactory.setDefaultAuthenticator(CredentialsManager.getAuthenticator()); // Register the application-specific 'bookmark' protocol. FileFactory.registerProtocol( BookmarkProtocolProvider.BOOKMARK, new com.mucommander.bookmark.file.BookmarkProtocolProvider()); }
@Override protected void jobCompleted() { super.jobCompleted(); // If the source files are located inside an archive, optimize the archive file AbstractArchiveFile sourceArchiveFile = getBaseSourceFolder() == null ? null : getBaseSourceFolder().getParentArchive(); if (sourceArchiveFile != null && sourceArchiveFile.isArchive() && sourceArchiveFile.isWritable()) optimizeArchive((AbstractRWArchiveFile) sourceArchiveFile); // If the destination files are located inside an archive, optimize the archive file, only if // the destination // archive is different from the source one AbstractArchiveFile destArchiveFile = baseDestFolder.getParentArchive(); if (destArchiveFile != null && destArchiveFile.isArchive() && destArchiveFile.isWritable() && !(sourceArchiveFile != null && destArchiveFile.equalsCanonical(sourceArchiveFile))) optimizeArchive((AbstractRWArchiveFile) destArchiveFile); // If this job corresponds to a file renaming in the same directory, select the renamed file // in the active table after this job has finished (and hasn't been cancelled) if (files.size() == 1 && newName != null && baseDestFolder.equalsCanonical(files.elementAt(0).getParent())) { // Resolve new file instance now that it exists: some remote files do not immediately update // file attributes // after creation, we need to get an instance that reflects the newly created file attributes selectFileWhenFinished(FileFactory.getFile(baseDestFolder.getAbsolutePath(true) + newName)); } }
@Override public AbstractFile getRoot() { FileURL rootURL = (FileURL) getURL().clone(); String rootPath = getRootPath(); rootURL.setPath("/" + vmIdentifier + "/" + rootPath); return FileFactory.getFile(rootURL); }
public Vector<String> getPossibleCompletions(String path) { Vector<String> result = new Vector<String>(); int index = Math.max(path.lastIndexOf('\\'), path.lastIndexOf('/')); if (index != -1) { String currentDirectoryName = path.substring(0, index + 1); AbstractFile currentDirectory = FileFactory.getFile(currentDirectoryName); if (currentDirectory != null && currentDirectory.exists()) { long currentDirectoryDate = currentDirectory.getDate(); if (cachedDirectoryName == null || !cachedDirectoryName.equals(currentDirectoryName) || currentDirectoryDate != cachedDirectoryDate) { AbstractFile[] currentDirectoryFiles; try { currentDirectoryFiles = getFiles(currentDirectory); } catch (IOException e) { LOGGER.debug("Caught exception", e); return new Vector<String>(); } int nbCurrentDirectoryFiles = currentDirectoryFiles.length; cachedDirectoryFileNames = new String[nbCurrentDirectoryFiles]; for (int i = 0; i < nbCurrentDirectoryFiles; i++) { AbstractFile abstractFileI = currentDirectoryFiles[i]; cachedDirectoryFileNames[i] = abstractFileI.getName() + (abstractFileI.isDirectory() ? abstractFileI.getSeparator() : ""); } Arrays.sort(cachedDirectoryFileNames, String.CASE_INSENSITIVE_ORDER); cachedDirectoryName = currentDirectory.getAbsolutePath() + (currentDirectory.isDirectory() ? "" : currentDirectory.getSeparator()); cachedDirectoryDate = currentDirectoryDate; } final String prefix = index == path.length() - 1 ? null : path.substring(index + 1).toLowerCase(); result = PrefixFilter.createPrefixFilter(prefix).filter(cachedDirectoryFileNames); } } return result; }
/** * Creates a returns a temporary local file/directory with the same extension as the specified * file/directory (guaranteed), and the same filename as much as possible (best effort). This * method returns <code>null</code> if the temporary file/directory could not be created. * * @param nonLocalFile the non-local file for which to create a temporary file. * @return a temporary local file/directory with the same extension as the specified * file/directory */ protected LocalFile createTempLocalFile(AbstractFile nonLocalFile) { try { // Note: the returned temporary file may be an AbstractArchiveFile if the filename's extension // corresponds // to a registered archive format LocalFile tempFile = FileFactory.getTemporaryFile(nonLocalFile.getName(), false).getAncestor(LocalFile.class); // create a directory if (nonLocalFile.isDirectory()) { tempFile.mkdir(); } else { // create a regular file tempFile.getOutputStream().close(); } return tempFile; } catch (IOException e) { return null; } }
@Override protected void jobCompleted() { super.jobCompleted(); // If the destination files are located inside an archive, optimize the archive file AbstractArchiveFile archiveFile = baseDestFolder.getParentArchive(); if (archiveFile != null && archiveFile.isArchive() && archiveFile.isWritable()) optimizeArchive((AbstractRWArchiveFile) archiveFile); // If this job correponds to a 'local copy' of a single file and in the same directory, // select the copied file in the active table after this job has finished (and hasn't been // cancelled) if (files.size() == 1 && newName != null && baseDestFolder.equalsCanonical(files.elementAt(0).getParent())) { // Resolve new file instance now that it exists: some remote files do not immediately update // file attributes // after creation, we need to get an instance that reflects the newly created file attributes selectFileWhenFinished(FileFactory.getFile(baseDestFolder.getAbsolutePath(true) + newName)); } }