if(resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER) checksumFile = resolvedDest.getDestinationFile().getDirectChild(getChecksumFilename(algorithm)); else checksumFile = resolvedDest.getDestinationFile();
AbstractArchiveFile parentArchiveFile = baseFolder.getParentArchive(); TransferFileJob job; String newName = resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER?null:resolvedDest.getDestinationFile().getName(); parentArchiveFile, PathUtils.getDepth(baseFolder.getAbsolutePath(), baseFolder.getSeparator()) - PathUtils.getDepth(parentArchiveFile.getAbsolutePath(), parentArchiveFile.getSeparator()), resolvedDest.getDestinationFolder(), newName, defaultFileExistsAction, mainFrame, files, resolvedDest.getDestinationFolder(), newName, TransferMode.COPY,
return new ResolvedDestination(destFile, ResolvedDestination.EXISTING_FOLDER, destFile); return null; return new ResolvedDestination(destFile, destFileExists?ResolvedDestination.EXISTING_FILE:ResolvedDestination.NEW_FILE, destParent);
/** * Executes the split job. */ private void startJob() { long size = getBytes(); if (size < 1) { return; } String destPath = edtTargetDirectory.getText(); PathUtils.ResolvedDestination resolvedDest = PathUtils.resolveDestination(destPath, mainFrame.getActivePanel().getCurrentFolder()); // The path entered doesn't correspond to any existing folder if (resolvedDest==null || (files.size()>1 && resolvedDest.getDestinationType()!=PathUtils.ResolvedDestination.EXISTING_FOLDER)) { showErrorDialog(Translator.get("invalid_path", destPath), Translator.get("split_file_dialog.error_title")); return; } long parts = getParts(); if (parts > MAX_PARTS) { showErrorDialog(Translator.get("split_file_dialog.max_parts", Integer.toString(MAX_PARTS)), Translator.get("split_file_dialog.error_title")); return; } ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("progress_dialog.processing_files")); SplitFileJob job = new SplitFileJob(progressDialog, mainFrame, file, resolvedDest.getDestinationFolder(), size, (int)parts); job.setIntegrityCheckEnabled(cbGenerateCRC.isSelected()); progressDialog.start(job); }
int destinationType = resolvedDest.getDestinationType(); if(destinationType==PathUtils.ResolvedDestination.EXISTING_FOLDER) { InformationDialog.showErrorDialog(mainFrame, Translator.get("directory_already_exists", enteredPath)); AbstractFile destFile = resolvedDest.getDestinationFile();
/** * Asserts that the <code>ResolvedDestination</code> returned by {@link PathUtils#resolveDestination(String, com.mucommander.commons.file.AbstractFile)} * matches the expected destination file and type. This method asserts that the destination folder is not * <code>null</code> and consistent with the destination file. * * @param resolvedDestination the ResolvedDestination to test * @param expectedDestinationFile the expected destination file * @param expectedDestinationType the expected destination type */ private void assertResult(PathUtils.ResolvedDestination resolvedDestination, AbstractFile expectedDestinationFile, int expectedDestinationType) { AbstractFile file = resolvedDestination.getDestinationFile(); int type = resolvedDestination.getDestinationType(); AbstractFile folder = resolvedDestination.getDestinationFolder(); assert file != null; assert folder != null; assert expectedDestinationFile.equals(file); assert expectedDestinationType == type; if(type==PathUtils.ResolvedDestination.EXISTING_FOLDER) assert file.equals(folder); else assert file.getParent().equals(folder); }
/** * This method checks that the given resolved destination is valid. This implementation returns <code>true</code> * if the resolved destination is not <code>null</code> and, in case there is more than one file to process, if the * destination is a folder that exists. This method can safely be overridden by subclasses to change the behavior. * <p> * Returning <code>true</code> will cause the job to go ahead and be started. Returning <code>false</code> will * pop up an error dialog that notifies the user that the path is incorrect. * </p> * <p> * This method is called from a dedicated thread so that it can safely perform I/O operations without any chance * of locking the event thread. * </p> * * @param resolvedDest the resolved destination * @param destPath the path, as it was entered in the path field * @return <code>true</code> if the given resolved destination is valid */ protected boolean isValidDestination(PathUtils.ResolvedDestination resolvedDest, String destPath) { return (resolvedDest!=null && (files.size()==1 || resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER)); }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) { int destinationType = resolvedDest.getDestinationType(); if(destinationType==PathUtils.ResolvedDestination.EXISTING_FILE) { showErrorDialog(Translator.get("invalid_path", resolvedDest.getDestinationFile().getAbsolutePath())); return null; } return new UnpackJob( progressDialog, mainFrame, files, destinationType==PathUtils.ResolvedDestination.NEW_FILE?resolvedDest.getDestinationFile():resolvedDest.getDestinationFolder(), defaultFileExistsAction); }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, ResolvedDestination resolvedDest, int defaultFileExistsAction) { return new CombineFilesJob(progressDialog, mainFrame, files, resolvedDest.getDestinationFile(), defaultFileExistsAction); }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) { return new MoveJob( progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER?null:resolvedDest.getDestinationFile().getName(), defaultFileExistsAction, false); }
@Override protected boolean isValidDestination(PathUtils.ResolvedDestination resolvedDest, String destPath) { if(resolvedDest==null) return false; int destType = resolvedDest.getDestinationType(); return destType==PathUtils.ResolvedDestination.NEW_FILE || destType==PathUtils.ResolvedDestination.EXISTING_FILE; }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) { // Remember last format used, for next time this dialog is invoked lastFormat = formats[formatsComboBox.getSelectedIndex()]; return new ArchiveJob(progressDialog, mainFrame, files, resolvedDest.getDestinationFile(), lastFormat, Archiver.formatSupportsComment(lastFormat)?commentArea.getText():null); }
@Override protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) { return new CopyJob( progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), resolvedDest.getDestinationType()==PathUtils.ResolvedDestination.EXISTING_FOLDER?null:resolvedDest.getDestinationFile().getName(), TransferMode.DOWNLOAD, defaultFileExistsAction); }