@Override public boolean isFolder() { return delegate.isFolder(); }
public boolean isFolder() { return (parent == null) || leader.isFolder(); }
public boolean isFolder() { return fileObj.isFolder(); }
@Override public FileObject process(FileObject obj, Collection<FileObject> coll) { FileObject fo = obj; if (folders) { return fo.isFolder() ? fo : null; } else { return fo.isData() ? fo : null; } } }
private static URL toURL(File fFile, FileObject fo) throws MalformedURLException { URL retVal = Utilities.toURI(fFile).toURL(); if (retVal != null && fo.isFolder()) { // #155742,160333 - URL for folder must always end with slash final String urlDef = retVal.toExternalForm(); final String pathSeparator = "/";//NOI18N if (!urlDef.endsWith(pathSeparator)) { retVal = new URL(urlDef + pathSeparator); } } return retVal; }
@Override public FileObject getFileObject(String name, String ext) { if (maskFile.isFolder()) { return maskFile.getFileObject(name, ext); } else { return null; } }
@Override public FileObject getFileObject(String relativePath) { if (maskFile.isFolder()) { return maskFile.getFileObject(relativePath); } else { return null; } }
static boolean affectsOrder(FileAttributeEvent event) { String name = event.getName(); if (name == null) { // Unknown attrs changed. Conservatively assume it might affect order. return true; } return name.equals(ATTR_POSITION) || (event.getFile().isFolder() && name.indexOf('/') != -1); }
private static String encodeFoPart(FileObject fo) { String path = fo.getPath(); if (fo.isFolder()) { path += "/"; } if (!fo.isRoot()) { path = "/" + path; } try { return new URI(null, path, null).toString(); } catch (URISyntaxException x) { return "???"; } }
/** Get a header field (currently, content type only). * @param name the header name. Only <code>content-type</code> is guaranteed to be present. * @return the value (i.e., MIME type) */ public String getHeaderField(String name) { if (name.equalsIgnoreCase("content-type")) { // NOI18N try { connect(); if (fo.isFolder()) { return "text/html"; // NOI18N } else { return fo.getMIMEType(); } } catch (IOException e) { } } return super.getHeaderField(name); }
/** Finds a config object under given path. The path contains the extension * of a file e.g.: * <pre> * Actions/Edit/org-openide-actions-CopyAction.instance * Services/Browsers/swing-browser.settings * </pre> * @param filePath path to .instance or .settings file * @param type the requested type for given object * @return either null or instance of requrested type * @since 7.49 */ public static <T> T getConfigObject(String path, Class<T> type) { FileObject fo = getConfigFile(path); if (fo == null || fo.isFolder()) { return null; } return NamedServicesProvider.getConfigObject(path, type); }
/** Fired when a file is deleted. * @param fe the event describing context where action has taken place */ public void fileDeleted(FileEvent fe) { if (fe.getFile().isFolder()) { updateAll(); } else { refreshAfterEvent(fe); } }
/** Removes listener previously added by {@link #addRecursiveListener(org.openide.filesystems.FileChangeListener)} * * @param fcl the listener to remove * @since 7.28 */ public void removeRecursiveListener(FileChangeListener fcl) { if (!isFolder()) { removeFileChangeListener(fcl); return; } try { getFileSystem().removeFileChangeListener(new RecursiveListener(this, fcl, false)); } catch (FileStateInvalidException ex) { ExternalUtil.LOG.log(Level.FINE, "Cannot remove listener from " + this, ex); } }
/** Get fully-qualified filename, but without extension. * Like {@link #getPackageNameExt} but omits the extension. * @param separatorChar char to separate folders and files * @return the fully-qualified filename * @deprecated Please use the <a href="@org-netbeans-api-java-classpath@/org/netbeans/api/java/classpath/ClassPath.html">ClassPath API</a> instead. */ @Deprecated public String getPackageName(char separatorChar) { assert false : "Deprecated."; if (isRoot() || getParent().isRoot()) { return (isFolder()) ? getNameExt() : getName(); } StringBuilder[] arr = new StringBuilder[1]; String name = getName(); getParent().constructName(arr, separatorChar, name.length()); arr[0].append(separatorChar).append(name); return arr[0].toString(); }
@Deprecated public FileObject find(String aPackage, String name, String ext) { // create enumeration of name to look for Enumeration<String> st = NbCollections.checkedEnumerationByFilter(new StringTokenizer(aPackage, "."), String.class, true); // NOI18N if ((name == null) || (ext == null)) { // search for folder, return the object only if it is folder FileObject fo = getAbstractRoot().find(st); return ((fo != null) && fo.isFolder()) ? fo : null; } else { Enumeration<String> en = Enumerations.concat(st, Enumerations.singleton(name + '.' + ext)); // tries to find it (can return null) return getAbstractRoot().find(en); } }
public InputStream getInputStream() throws IOException, UnknownServiceException { connect(); if (iStream == null) { try { if (fo.isFolder()) { iStream = new FIS(fo); } else { iStream = fo.getInputStream(); } } catch (FileNotFoundException e) { ExternalUtil.exception(e); throw e; } } return iStream; }
public OutputStream getOutputStream() throws IOException, UnknownServiceException { connect(); if (fo.isFolder()) { throw new UnknownServiceException(); } if (oStream == null) { FileLock flock = fo.lock(); oStream = new LockOS(fo.getOutputStream(flock), flock); } return oStream; }
public @Override URL getURL(FileObject fo, int type) { if (type != URLMapper.INTERNAL) { return null; } try { FileSystem fs = fo.getFileSystem(); if (fs instanceof MemoryFileSystem) { String path = fo.getPath(); if (fo.isFolder() && !fo.isRoot()) { path += '/'; } return url((MemoryFileSystem) fs, path); } } catch (FileStateInvalidException x) { // ignore } return null; } // keep as separate method to avoid linking Handler until needed
private void someChange() { FileChangeListener listener; boolean wasOnTarget; FileObject currentNew; synchronized (this) { if (current == null) { return; } listener = get(); if (listener == null) { return; } wasOnTarget = isOnTarget; locateCurrent(); currentNew = current; } if (isOnTarget && !wasOnTarget) { // fire events about itself creation (it is difference from FCL // on FileOject - it cannot be fired because we attach FCL on already existing FileOject if (currentNew.isFolder()) { listener.fileFolderCreated(new FileEvent(currentNew)); } else { listener.fileDataCreated(new FileEvent(currentNew)); } } }
/** Copies this file. This allows the filesystem to perform any additional * operation associated with the copy. But the default implementation is simple * copy of the file and its attributes * * @param target target folder to move this file to * @param name new basename of file * @param ext new extension of file (ignored for folders) * @return the newly created file object representing the moved file */ public FileObject copy(FileObject target, String name, String ext) throws IOException { if (isFolder()) { if (FileUtil.isParentOf(this, target)) { throw new FSException(NbBundle.getMessage(FileObject.class, "EXC_OperateChild", this, target)); // NOI18N } FileObject peer = target.createFolder(name); FileUtil.copyAttributes(this, peer); for (FileObject fo : getChildren()) { fo.copy(peer, fo.getName(), fo.getExt()); } return peer; } FileObject dest = FileUtil.copyFileImpl(this, target, name, ext); return dest; }