public String getExt() { if(ext == null) { ext = fileObj.getExt(); } return ext; }
@Override public String getExt() { return delegate.getExt(); }
static boolean isMaskFile(FileObject fo) { return fo.getExt().endsWith(MASK); }
/** 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); }
/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * Uses the extension of the source file. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @return the created file object in the destination folder * @exception IOException if <code>destFolder</code> is not a folder or does not exist; the destination file already exists; or * another critical error occurs during copying */ public static FileObject copyFile(FileObject source, FileObject destFolder, String newName) throws IOException { return copyFile(source, destFolder, newName, source.getExt()); }
/** Test whether this file has the specified extension. * @param ext the extension the file should have * @return true if the text after the last period (<code>.</code>) is equal to the given extension */ public final boolean hasExt(String ext) { if (isHasExtOverride()) { return hasExtOverride(ext); } return getExt().equals(ext); }
/** 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(); }
/** Moves file to the selected folder. * This implementation uses a copy-and-delete mechanism, and automatically uses the necessary lock. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @return new file object * @exception IOException if either the {@link #copyFile copy} or {@link FileObject#delete delete} failed */ public static FileObject moveFile(FileObject source, FileObject destFolder, String newName) throws IOException { FileLock lock = null; try { lock = source.lock(); return source.move(lock, destFolder, newName, source.getExt()); } finally { if (lock != null) { lock.releaseLock(); } } }
private boolean accept(FileObject fo) throws IOException { String ext = fo.getExt(); if (ext == null) { ext = EMPTY_EXTENSION; String s = getMIMEType(fo.getExt()); //from the very first implementation there is still question "how to obtain resource MIME type as classified by lower layers?" if (s == null) return false;
if (fileObject.getExt().endsWith("_hidden")) { // NOI18N mis.remove();
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); } }
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 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); } } } }
/** 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; }
/** 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; }
@Override public Boolean convert(FileObject p) { return FileObjects.JAVA.equalsIgnoreCase(p.getExt()); } };
@Override public Boolean convert(FileObject p) { return FileObjects.CLASS.equalsIgnoreCase(p.getExt()); } };
private SmartOutputStream(FileObject fileObject, FileLock lock) throws IOException { this.fileObject = fileObject; this.lock = lock; this.tempFile = File.createTempFile(fileObject.getName(), "."+fileObject.getExt()); // NOI18N this.delegate = new FileOutputStream(tempFile); this.checksum = new Adler32(); }
public static boolean hasVirtualSource (final FileObject file) { Parameters.notNull("file", file); final String ext = file.getExt(); return getExt2ProvMap().keySet().contains(ext); }