public FileObject getParent() { return fileObj.getParent(); }
/** Method that goes upon list of folders and updates its locks. This is used when * an object is masked which may lead to creation of folders on a disk. * * @param fo folder to check * @exception IOException if something locks cannot be updated */ private static void updateFoldersLock(FileObject fo) throws IOException { while (fo != null) { MultiFileObject mfo = (MultiFileObject) fo; MfLock l = (mfo.lock == null) ? null : mfo.lock.get(); if (l != null) { // the file has been locked => update the lock mfo.writable(true); } fo = fo.getParent(); } }
/** Test whether there is a file with the same basename and only a changed extension in the same folder. * The default implementation asks this file's parent using {@link #getFileObject(String name, String ext)}. * * @param ext the alternate extension * @return true if there is such a file */ public boolean existsExt(String ext) { FileObject parent = getParent(); return (parent != null) && (parent.getFileObject(getName(), ext) != null); }
buff.append("<BODY>\n"); // NOI18N FileObject parent = folder.getParent();
String nameExt = st.nextToken(); if (nameExt.equals("..")) { // NOI18N myObj = myObj.getParent(); } else { if (!nameExt.equals(".")) {
/** Finds brother file with same base name but different extension. * @param fo the file to find the brother for or <CODE>null</CODE> * @param ext extension for the brother file * @return a brother file (with the requested extension and the same parent folder as the original) or * <CODE>null</CODE> if the brother file does not exist or the original file was <CODE>null</CODE> */ public static FileObject findBrother(FileObject fo, String ext) { if (fo == null) { return null; } FileObject parent = fo.getParent(); if (parent == null) { return null; } return parent.getFileObject(fo.getName(), ext); }
/** 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()); }
protected void delete(String name) throws IOException { File file = getFile(name); if (deleteFile(file) != SUCCESS) { if (file.exists()) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath())); } else { /** When file externaly deleted and fo.delete () is called before periodical refresh */ FileObject thisFo = findResource(name); if (thisFo != null) { if (thisFo.getParent() != null) { thisFo.getParent().refresh(); } thisFo.refresh(); if (thisFo.isValid()) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath())); } } } } }
/** Moves this file. This allows the filesystem to perform any additional * operation associated with the move. But the default implementation is encapsulated * as copy and delete. * * @param lock File must be locked before renaming. * @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 move(FileLock lock, FileObject target, String name, String ext) throws IOException { if (getParent().equals(target)) { // it is possible to do only rename rename(lock, name, ext); return this; } else { // have to do copy FileObject dest = copy(target, name, ext); delete(lock); FileObjectLkp.reassign(this, dest); return dest; } }
FileObject d = children.get(0).getParent(); for (String attr : NbCollections.iterable(d.getAttributes())) { if (attr.indexOf('/') != -1 && d.getAttribute(attr) instanceof Boolean) {
static String getPackageName(final FileObject createdClass) { FileObject parent = createdClass.getParent(); // XXX bad. Acquire source directory though 'src.dir' property or some Scala's ClassPath while (parent != null && !"src".equals(parent.getNameExt())) { parent = parent.getParent(); } return (parent == null) ? "test" // fallback : createdClass.getParent().getPath().substring(parent.getPath().length() + 1).replace('/', '.'); }
/** * @return true if the given file represents the lib dir of a gem, e.g. * <code>$GEM_HOME/mygem-0.1/lib</code>, false otherwise. This is useful * for {@link #getSystemRoot(libDirFO)} to be able to return an indexed root * (the lib dirs of gems are indexed roots). See also IZ 167814. */ private boolean isGemRoot(FileObject file) { for (int i = 0; i < 3 && file != null; i++) { file = file.getParent(); } return file != null && file.isFolder() && file.equals(getGemHome()); }
private String getTargetPackageName(FileObject fo){ String newPackageName = RefactoringUtil.getPackageName(move.getTarget().lookup(URL.class)); String postfix = FileUtil.getRelativePath(this.folder.getParent(), fo).replace('/', '.'); if (newPackageName.length() == 0){ return postfix; } if (postfix.length() == 0){ return newPackageName; } return newPackageName + "." + postfix; }
public void fileDeleted (FileEvent fe) { FileObject fo = fe.getFile (); String mimeType = fo.getParent ().getName (); languageChanged (mimeType); } public void fileFolderCreated (FileEvent fe) {