/** * Adds all the files in the given array to this FileSet. Does nothing if the specified array is <code>null</code. * * @param files the files to add to this FileSet. */ public void addAll(AbstractFile[] files) { if(files==null) return; for (AbstractFile file : files) add(file); } }
/** * Creates a new empty FileSet with the specified base folder, and adds the given file. * * @param baseFolder the folder containing the files * @param file the file to add */ public FileSet(AbstractFile baseFolder, AbstractFile file) { this.baseFolder = baseFolder; add(file); }
/** * Returns a {@link com.mucommander.commons.file.util.FileSet FileSet} with all currently marked files. * <p> * The returned <code>FileSet</code> is a freshly created instance, so it can be safely modified. & However, it won't be kept current : the returned FileSet is just a snapshot * which might not reflect the current marked files state after this method has returned and additional * files have been marked/unmarked. * </p> * * @return a FileSet containing all the files that are currently marked */ public synchronized FileSet getMarkedFiles() { FileSet markedFiles = new FileSet(currentFolder, nbRowsMarked); int nbRows = getRowCount(); if(parent==null) { for(int i=0; i<nbRows; i++) { if(rowMarked[fileArrayIndex[i]]) markedFiles.add(getFileAtRow(i)); } } else { for(int i=1, iMinusOne=0; i<nbRows; i++) { if(rowMarked[fileArrayIndex[iMinusOne]]) markedFiles.add(getFileAtRow(i)); iMinusOne = i; } } return markedFiles; }
/** * Returns selected files in a {@link FileSet}. Selected files are either the marked files or the currently selected * file if no file is currently marked. The parent folder '..' is never included in the returned set. * * @return selected files in a FileSet */ public FileSet getSelectedFiles() { FileSet selectedFiles = tableModel.getMarkedFiles(); // if no row is marked, then add selected row if there is one, and if it is not parent folder if(selectedFiles.size()==0) { AbstractFile selectedFile = getSelectedFile(); if(selectedFile!=null) selectedFiles.add(selectedFile); } return selectedFiles; }
/** * Displays a download dialog box where the user can choose where to download the given file or cancel * the operation. * * @param file the file to download */ private void showDownloadDialog(AbstractFile file) { FileSet fileSet = new FileSet(locationManager.getCurrentFolder()); fileSet.add(file); // Show confirmation/path modification dialog new DownloadDialog(mainFrame, fileSet).showDialog(); }
/** * Adds the given file to the FileSet if it's not a folder, recurses otherwise. */ private void recurseOnFolder(AbstractFile file, FileSet flattenedFiles) throws IOException { if(file.isDirectory() && !file.isSymlink()) { AbstractFile children[] = file.ls(); for (AbstractFile child : children) recurseOnFolder(child, flattenedFiles); } else { flattenedFiles.add(file); } }
for(int i=0; i<nbFiles; i++) if(fileCheckboxes[i].isSelected()) filesToSend.add(flattenedFiles.elementAt(i));
/** * Adds a dummy output file (used in progress monitoring). * @param i index of a file * @param size size of a file */ private void addDummyFile(int i, long size) { String num; if (i<10) { num = "00" + Integer.toString(i); } else if (i<100) { num = "0" + Integer.toString(i); } else { num = Integer.toString(i); } FileURL childURL = (FileURL)destFolder.getURL().clone(); childURL.setPath(destFolder.addTrailingSeparator(childURL.getPath()) + sourceFile.getName() + "." + num); DummyDestFile fileHolder = new DummyDestFile(childURL, size); files.add(fileHolder); }
/** * Renames the currently edited name cell, only if the filename has changed. */ private void rename() { String newName = filenameField.getText(); AbstractFile fileToRename = tableModel.getFileAtRow(editingRow); if(!newName.equals(fileToRename.getName())) { AbstractFile current; current = folderPanel.getCurrentFolder(); // Starts moving files ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("move_dialog.moving")); FileSet files = new FileSet(current); files.add(fileToRename); MoveJob renameJob = new MoveJob(progressDialog, mainFrame, files, current, newName, FileCollisionDialog.ASK_ACTION, true); progressDialog.start(renameJob); } }
@Override protected boolean processFile(AbstractFile file, Object recurseParams) { if(!super.processFile(file, recurseParams)) return false; // TODO: temporary files seem to be left after the JVM quits under Mac OS X, even if the files permissions are unchanged // Add the file to the list of files to open, only if it is one of the top-level files if(filesToOpen.indexOf(file)!=-1) { if(!currentDestFile.isDirectory()) { // Do not change directories' permissions try { // Make the temporary file read only if(currentDestFile.getChangeablePermissions().getBitValue(PermissionAccess.USER, PermissionType.WRITE)) currentDestFile.changePermission(PermissionAccess.USER, PermissionType.WRITE, false); } catch(IOException e) { LOGGER.debug("Caught exeception while changing permissions of "+currentDestFile, e); return false; } } tempFiles.add(currentDestFile); } return true; }
int partIdx = Integer.parseInt(ext2); if (partIdx > firstIndex) files.add(otherPart); } catch (NumberFormatException e) {
fileSet.add(destFile);