@Override public boolean isRoot() { return delegate.isRoot(); }
public boolean isRoot() { return fileObj.isRoot(); }
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 "???"; } }
private static String getArchiveDisplayName(FileObject fo, FileObject archiveFile) { String displayName = null; File f = FileUtil.toFile(archiveFile); if (f != null) { String archivDisplayName = f.getAbsolutePath(); if (fo.isRoot()) { displayName = archivDisplayName; } else { String entryPath = fo.getPath(); displayName = NbBundle.getMessage( FileUtil.class, "LBL_file_in_filesystem", entryPath, archivDisplayName ); } } return displayName; }
/** * Gets a textual represtentation of this <code>FileObject</code>. * The precise format is not defined. In particular it is probably * <em>not</em> a resource path. * For that purpose use {@link #getPath} directly. * <p>Typically it is useful for debugging purposes. Example of correct usage: * <pre> * <font class="type">FileObject</font> <font class="variable-name">fo</font> = getSomeFileObject(); * ErrorManager.getDefault().log(<font class="string">"Got a change from "</font> + fo); * </pre> * @return some representation of this file object */ @Override public String toString() { String cname = getClass().getName(); String cnameShort = cname.substring(cname.lastIndexOf('.') + 1); try { return cnameShort + '@' + Integer.toHexString(System.identityHashCode(this)) + '[' + (isRoot() ? "root of " + getFileSystem() : getPath()) + ']'; // NOI18N } catch (FileStateInvalidException x) { return cnameShort + '@' + Integer.toHexString(System.identityHashCode(this)) + "[???]"; // NOI18N } }
private boolean setAttributeOnFO(FileObject fo, String attrToSet, Object value, boolean fire) throws IOException { if (fo instanceof AbstractFolder) { ((AbstractFolder) fo).setAttribute(attrToSet, value, false); } else { /** cannot disable firing from underlaying delegate if not AbstractFolder * without API change. So I don`t fire events from this method with one * exception - root. */ fire = fire && fo.isRoot(); fo.setAttribute(attrToSet, value); } return fire; }
/** 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(); }
/** Get fully-qualified filename. Does so by walking through all folders * to the root of the filesystem. Separates files with provided <code>separatorChar</code>. * The extension, if present, is separated from the basename with <code>extSepChar</code>. * <p><strong>Note:</strong> <samp>fo.getPath()</samp> will have the * same effect as using this method with <samp>/</samp> and <samp>.</samp> (the standard * path and extension delimiters). * @param separatorChar char to separate folders and files * @param extSepChar char to separate extension * @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 getPackageNameExt(char separatorChar, char extSepChar) { assert false : "Deprecated."; if (isRoot() || getParent().isRoot()) { return getNameExt(); } StringBuilder[] arr = new StringBuilder[1]; getParent().constructName(arr, separatorChar, 50); String ext = getExt(); if ((ext == null) || ext.equals("")) { // NOI18N arr[0].append(separatorChar).append(getNameExt()); } else { arr[0].append(separatorChar).append(getName()).append(extSepChar).append(getExt()); } return arr[0].toString(); }
/** Constructs path of file. * @param arr to place the string buffer * @param sepChar separator character */ private void constructName(StringBuilder[] arr, char sepChar, int lengthSoFar) { String myName = getNameExt(); int myLen = lengthSoFar + myName.length(); FileObject parent = getParent(); if (parent == this) { Object fs; try { fs = getFileSystem(); } catch (IOException ex) { fs = "unknown"; // NOI18N } throw new IllegalStateException("Dangerous self-reproductive parentship: " + this + " type: " + getClass() + " fs: " + fs); // NOI18N } if ((parent != null) && !parent.isRoot()) { parent.constructName(arr, sepChar, myLen + 1); arr[0].append(sepChar); } else { assert arr[0] == null; arr[0] = new StringBuilder(myLen); } arr[0].append(getNameExt()); }
String prefix = fo.isRoot() ? dirName : (fo.getPath() + '/' + dirName);
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
retURL = new URL( "jar:" + Utilities.toURI(new File(f,toReplace + fo.getPath())).toString().replaceFirst("/"+toReplace,"!/") + // NOI18N ((fo.isFolder() && !fo.isRoot()) ? "/" : "")
fo.isRoot() && !mfs.canHaveRootAttributeOnReadOnlyFS(WEIGHT_ATTRIBUTE) ? 0 : weightOf(fo, writable);
if (fo.isRoot()) { displayName = fo.getFileSystem().getDisplayName(); } else {
if (localFo.isRoot() && (prefixattr != null)) { try { FileSystem foFs = localFo.getFileSystem();
public boolean isRoot() { return fileObj.isRoot(); }
/** Constructs path of file. * @param sb string buffer * @param sepChar separator character */ private void constructName (StringBuffer sb, char sepChar) { FileObject parent = getParent (); if ((parent != null) && !parent.isRoot ()) { parent.constructName (sb, sepChar); sb.append (sepChar); } sb.append (getNameExt ()); }
/** Constructs path of file. * @param sb string buffer * @param sepChar separator character */ private void constructName (StringBuffer sb, char sepChar) { FileObject parent = getParent (); if ((parent != null) && !parent.isRoot ()) { parent.constructName (sb, sepChar); sb.append (sepChar); } sb.append (getNameExt ()); }
public boolean isRenameAllowed () { FileObject fo = getPrimaryFile (); return !fo.isRoot() && !fo.isReadOnly (); }
public void setName (String name) { try { if (!name.equals (obj.getName ())) { obj.rename (name); if (obj.original.getPrimaryFile ().isRoot ()) { obj.getPrimaryFile ().setAttribute (ATTR_USEOWNNAME, Boolean.TRUE); } fireDisplayNameChange (null, null); fireNameChange (null, null); } } catch (IOException ex) { throw new IllegalArgumentException (ex.getMessage ()); } }