@Override public boolean accept(Local file) { return file.isDirectory(); } })) {
@Override public boolean accept(final Local file) { return file.isDirectory(); } }
@Override public int compare(final Local o1, final Local o2) { if(o1.isDirectory() && o2.isDirectory()) { return 0; } if(o1.isFile() && o2.isFile()) { return 0; } if(o1.isDirectory()) { return -1; } if(o2.isDirectory()) { return 1; } return 0; } }
@Override public boolean accept(Local file) { if(file.isDirectory()) { return false; } return "ini".equals(file.getExtension()); } })) {
@Override public boolean accept(Local file) { if(file.isDirectory()) { return true; } return "xml".equals(file.getExtension()); }
public boolean panel_shouldShowFilename(ID panel, String path) { final Local f = LocalFactory.get(path); if(f.isDirectory()) { return true; } final String extension = f.getExtension(); if(StringUtils.isEmpty(extension)) { return false; } return extension.equals("app"); } }
@Override public EnumSet<Type> getType() { final EnumSet<Type> set = EnumSet.noneOf(Type.class); if(this.isDirectory()) { set.add(Type.directory); if(this.isVolume()) { set.add(Type.volume); } } else { set.add(Type.file); } if(this.isSymbolicLink()) { set.add(Type.symboliclink); } return set; }
private void upload(final Host bookmark, final List<Local> files, final Path destination) { final List<TransferItem> roots = new ArrayList<TransferItem>(); for(Local file : files) { roots.add(new TransferItem(new Path(destination, file.getName(), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file)), file)); } final TransferController t = TransferControllerFactory.get(); t.start(new UploadTransfer(bookmark, roots), new TransferOptions()); }
@Override public List<TransferItem> list(final Session<?> session, final Path remote, final Local directory, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List children for %s", directory)); } if(directory.isSymbolicLink()) { final Symlink symlink = session.getFeature(Symlink.class); if(new UploadSymlinkResolver(symlink, roots).resolve(directory)) { if(log.isDebugEnabled()) { log.debug(String.format("Do not list children for symbolic link %s", directory)); } // We can resolve the target of the symbolic link and will create a link on the remote system // using the symlink feature of the session return Collections.emptyList(); } } final List<TransferItem> children = new ArrayList<TransferItem>(); for(Local local : directory.list().filter(comparator, filter)) { children.add(new TransferItem(new Path(remote, local.getName(), local.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file)), local)); } return children; }
if(directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(String.format("glob:%s", FilenameUtils.getName(path))); final Set<TransferItem> items = new HashSet<TransferItem>();
@Override protected void parse(final ProtocolFactory protocols, final Local folder) throws AccessDeniedException { for(Local child : folder.list().filter(new NullFilter<Local>() { @Override public boolean accept(Local file) { if(file.isDirectory()) { return false; } return "ini".equals(file.getExtension()); } })) { if(child.isDirectory()) { this.parse(protocols, child); } else { this.read(protocols, child); } } }
@Override protected void parse(final ProtocolFactory protocols, final Local folder) throws AccessDeniedException { for(Local child : folder.list().filter(new Filter<Local>() { @Override public boolean accept(Local file) { if(file.isDirectory()) { return true; } return "xml".equals(file.getExtension()); } @Override public Pattern toPattern() { return Pattern.compile(".*\\.xml"); } })) { if(child.isDirectory()) { this.parse(protocols, child); } else { this.read(protocols, child); } } }
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) { final Local local = LocalFactory.get(input.getOptionValues(action.name())[1]); if(StringUtils.containsAny(remote.getName(), '*')) { // Treat asterisk as wildcard return Collections.singleton(new TransferItem(remote.getParent(), local)); } if(remote.isDirectory()) { // Remote path resolves to directory if(local.exists()) { return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName()))); } return Collections.singleton(new TransferItem(remote, local)); } // Remote path resolves to file if(local.isDirectory()) { // Append remote filename to local target return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName()))); } // Keep from input return Collections.singleton(new TransferItem(remote, local)); } }
protected TransferItem resolve(final Path remote, final Local local) { if(local.isDirectory()) { // Local path resolves to folder if(remote.isDirectory()) { // Append local name to remote target return new TransferItem(new Path(remote, local.getName(), EnumSet.of(Path.Type.directory)), local); } return new TransferItem(new Path(remote.getParent(), remote.getName(), EnumSet.of(Path.Type.directory)), local); } // Local path resolves to file if(remote.isDirectory()) { // Append local name to remote target return new TransferItem(new Path(remote, local.getName(), EnumSet.of(Path.Type.file)), local); } // Keep from input for file transfer return new TransferItem(remote, local); } }
/** * @param pboard Pasteboard with filenames * @return True if filenames are found in pasteboard and upload has started */ private boolean upload(NSPasteboard pboard) { if(!this.isMounted()) { return false; } if(pboard.availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.FilenamesPboardType)) != null) { NSObject o = pboard.propertyListForType(NSPasteboard.FilenamesPboardType); if(o != null) { if(o.isKindOfClass(Rococoa.createClass("NSArray", NSArray._Class.class))) { final NSArray elements = Rococoa.cast(o, NSArray.class); final Path workdir = this.workdir(); final List<TransferItem> uploads = new ArrayList<TransferItem>(); for(int i = 0; i < elements.count().intValue(); i++) { final Local local = LocalFactory.get(elements.objectAtIndex(new NSUInteger(i)).toString()); uploads.add(new TransferItem(new Path(workdir, local.getName(), local.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file)), local)); } this.transfer(new UploadTransfer(pool.getHost(), uploads)); } } } return false; }
local.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file)), local ));
final Local local = download.local; if(local.exists()) { if(local.isDirectory()) { if(local.list().isEmpty()) {
@Override public void run() { final NSOpenPanel panel = NSOpenPanel.openPanel(); panel.setCanChooseDirectories(file.isDirectory()); panel.setCanChooseFiles(file.isFile()); panel.setAllowsMultipleSelection(false); panel.setMessage(MessageFormat.format(LocaleFactory.localizedString("Select {0}", "Credentials"), file.getAbbreviatedPath())); panel.setPrompt(LocaleFactory.localizedString("Choose")); final NSInteger modal = panel.runModal(file.getParent().getAbsolute(), file.getName()); if(modal.intValue() == SheetCallback.DEFAULT_OPTION) { final NSArray filenames = panel.filenames(); final NSEnumerator enumerator = filenames.objectEnumerator(); NSObject next; while((next = enumerator.nextObject()) != null) { selected.set(new FinderLocal(next.toString())); } } panel.orderOut(null); } };
if(local.exists()) { if(file.getType().contains(Path.Type.file)) { if(local.isDirectory()) { throw new LocalAccessDeniedException(String.format("Cannot replace folder %s with file %s", local.getAbbreviatedPath(), file.getName()));
final Local local = LocalFactory.get(elements.objectAtIndex(new NSUInteger(i)).toString()); roots.add(new TransferItem(new Path(destination, local.getName(), local.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file)), local));