@Override public String getName() { return delegate.getName(); }
/** 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(); }
public String getName() { return fileObj.getName(); }
/** 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(); }
/** Check whether given resolver's FileObject is user defined. * @param mimeResolverFO resolver's FileObject * @return true if specified FileObject is user defined MIME resolver, false otherwise */ public static boolean isUserDefined(FileObject mimeResolverFO) { return mimeResolverFO.getAttribute(USER_DEFINED_MIME_RESOLVER) != null || mimeResolverFO.getName().equals(USER_DEFINED_MIME_RESOLVER); }
/** Converts the file to be writable. * The file has to be locked! * * @return file object (new leader) that is writable * @exception IOException if the object cannot be writable */ private FileObject writable(boolean copyContents) throws IOException { MultiFileSystem fs = getMultiFileSystem(); FileSystem single = fs.createWritableOn(getPath()); if (single != leader.getFileSystem()) { // if writing to a file that is not on writable fs => // copy it if (leader.isFolder()) { leader = FileUtil.createFolder(root(single), getPath()); } else { FileObject folder = FileUtil.createFolder(root(single), getParent().getPath()); if (copyContents) { leader = leader.copy(folder, leader.getName(), leader.getExt()); } else { leader = folder.createData(leader.getNameExt()); } } MfLock l = ((lock == null) ? null : lock.get()); if (l != null) { // update the lock l.addLock(leader); } } return leader; }
/** Getter for name and extension of a file object. Dot is used * as separator between name and ext. * @return string name of the file in the folder (with extension) */ public String getNameExt() { String n = getName(); String e = getExt(); return ((e == null) || (e.length() == 0)) ? n : (n + '.' + e); }
/** #26521, 114976 - ignore not readable and windows' locked files. */ private static void handleIOException(FileObject fo, IOException ioe) throws IOException { if (fo.canRead()) { if (!Utilities.isWindows() || !(ioe instanceof FileNotFoundException) || !fo.isValid() || !fo.getName().toLowerCase().contains("ntuser")) {//NOI18N throw ioe; } } }
/** 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); }
/** 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); }
public String getDisplayName() { String n = fo.getName(); try { n = fo.getFileSystem().getStatus().annotateName(n, Collections.singleton(fo)); } catch (FileStateInvalidException ex) { LOG.log(Level.WARNING, ex.getMessage(), ex); } return n; }
String name = fo.getName ();
private void refreshAfterEvent(FileEvent fe) { FileObject fFile = fe.getFile(); superRefresh(false); MultiFileObject mFile = (MultiFileObject) getFileObject(fFile.getName(), fFile.getExt()); if (mFile != null) { mFile.superRefresh(false); } }
/** Copies content of one folder into another. * @param source source folder * @param target target folder * @exception IOException if it fails */ private static void copyContent(FileObject source, FileObject target) throws IOException { FileObject[] srcArr = source.getChildren(); copyAttrs(source, target); //added for (int i = 0; i < srcArr.length; i++) { FileObject child = srcArr[i]; if (MultiFileSystem.isMaskFile(child)) { continue; } if (target.getFileObject(child.getName(), child.getExt()) == null) { if (child.isData()) { FileObject fo = FileUtil.copyFile(child, target, child.getName(), child.getExt()); if (fo != null) { copyAttrs(child, fo); } } else { FileObject targetChild = target.createFolder(child.getName()); copyContent(child, targetChild); } } } }
fo = en.nextElement(); String n = fo.getName(); String e = fo.getExt();
/** Fired when a file is changed. * @param fe the event describing context where action has taken place */ public void fileChanged(FileEvent fe) { FileObject changedFile = this; if (fe.getSource().equals(leader) && hasAtLeastOneListeners() && !fe.firedFrom(markAtomicAction)) { /**There should not dissapear information about source and changed file*/ if (!fe.getFile().equals(fe.getSource())) { changedFile = getFileObject(fe.getFile().getName(), fe.getFile().getExt()); } /**fileChanged1 - should not fire event for this.getParent (). * I think that already bottom layer forked event.*/ /** [PENDING] fix of #16926, #16895. But there should be investigated * why this MFO doesn`t know about child ?*/ if (changedFile != null) { fileChanged1(new FileEvent(this, changedFile, fe.getTime())); } } }
/** 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; }
@Override public void run() { try { for (int i = 0; i < selectedSnapshots.length; i++) { exportSnapshot(selectedSnapshots[i], dir[0], fileName[0] != null ? fileName[0] : selectedSnapshots[i].getName(), fileExt[0] != null ? fileExt[0] : selectedSnapshots[i].getExt()); } } finally { ph.finish(); } } });
private static FileObject getBundleInFolder(FileObject folder, String bundleName) { if (folder != null && folder.isValid() && folder.isFolder()) { for (FileObject fo : folder.getChildren()) { if (fo.getName().startsWith(bundleName) && "properties".equals(fo.getExt())) { //NOI18N return fo; } } } return null; }
@Override @NonNull public String getName() { final ProjectInformation d = delegate; return d != null ? d.getName() : project.getProjectDirectory().getName(); }