/** Finds a resource on given filesystem. The default * implementation simply uses FileSystem.findResource, but * subclasses may override this method to hide/show some * resources. * * @param fs the filesystem to scan on * @param res the resource name to look for * @return the file object or null */ protected FileObject findResourceOn(FileSystem fs, String res) { return fs.findResource(res); }
/** Find a resource in repository, ignoring not capable filesystems. * @param resName name of the resource * @deprecated Please use the <a href="@org-netbeans-api-java-classpath@/org/netbeans/api/java/classpath/ClassPath.html">ClassPath API</a> instead. */ @Deprecated public FileObject findResource(String resName) { Enumeration<? extends FileSystem> en = fileSystems(); while (en.hasMoreElements()) { FileSystem fs = en.nextElement(); FileObject fo = fs.findResource(resName); if (fo != null) { // object found return fo; } } return null; }
static FileObject find(URL url) { if (!Handler.PROTOCOL.equals(url.getProtocol())) { return null; } Matcher m = HOST.matcher(url.getHost()); if (!m.matches()) { return null; } Reference<FileSystem> r; synchronized (filesystems) { r = filesystems.get(Long.parseLong(m.group(1))); } if (r == null) { return null; } FileSystem fs = r.get(); if (fs == null) { return null; } return fs.findResource(url.getPath().substring(1)); } public @Override FileObject[] getFileObjects(URL url) {
/** Searches for the given resource among all filesystems, returning all matches. * @param name name of the resource * @return enumeration of {@link FileObject}s * @deprecated Please use the <a href="@org-netbeans-api-java-classpath@/org/netbeans/api/java/classpath/ClassPath.html">ClassPath API</a> instead. */ @Deprecated public final Enumeration<? extends FileObject> findAllResources(String name) { assert false : "Deprecated."; Vector<FileObject> v = new Vector<FileObject>(8); Enumeration<? extends FileSystem> en = getFileSystems(); while (en.hasMoreElements()) { FileSystem fs = en.nextElement(); FileObject fo = fs.findResource(name); if (fo != null) { v.addElement(fo); } } return v.elements(); }
/** Searches for the given resource among all filesystems * that satifies this capability, returning all matches. * @param name name of the resource * @return enumeration of {@link FileObject}s * @deprecated Please use the <a href="@org-netbeans-api-java-classpath@/org/netbeans/api/java/classpath/ClassPath.html">ClassPath API</a> instead. */ @Deprecated public Enumeration<? extends FileObject> findAllResources(String name) { Vector<FileObject> v = new Vector<FileObject>(8); Enumeration<? extends FileSystem> en = fileSystems(); while (en.hasMoreElements()) { FileSystem fs = en.nextElement(); FileObject fo = fs.findResource(name); if (fo != null) { v.addElement(fo); } } return v.elements(); }
/** Searches for the given resource among all filesystems. * @see FileSystem#findResource * @param name a name of the resource * @return file object or <code>null</code> if the resource can not be found * @deprecated Please use the <a href="@org-netbeans-api-java-classpath@/org/netbeans/api/java/classpath/ClassPath.html">ClassPath API</a> instead. */ @Deprecated public final FileObject findResource(String name) { assert false : "Deprecated."; Enumeration<? extends FileSystem> en = getFileSystems(); while (en.hasMoreElements()) { FileSystem fs = en.nextElement(); FileObject fo = fs.findResource(name); if (fo != null) { // object found return fo; } } return null; }
private static FileObject oldDecode(URL u) { String resourceName = u.getFile(); if (resourceName.startsWith("/")) { resourceName = resourceName.substring(1); // NOI18N } // first part is FS name int first = resourceName.indexOf('/'); // NOI18N if (first == -1) { return null; } String fileSystemName = oldDecodeFSName(resourceName.substring(0, first)); resourceName = resourceName.substring(first); FileSystem fsys = Repository.getDefault().findFileSystem(fileSystemName); return (fsys == null) ? null : fsys.findResource(resourceName); }
return findResource(bf.toString());
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); assert fsname != null : "Should always have a non-null fsname here"; @SuppressWarnings("deprecation") // historical part of serial form FileSystem fs = Repository.getDefault().findFileSystem(fsname); if (fs != null) { assert path != null : "Should always have a non-null path here"; f = fs.findResource(path); } if (f == null) { // Fall back to URL. assert url != null : "Should always have a non-null URL here"; f = URLMapper.findFileObject(url); if (f == null) { throw new FileNotFoundException("Could not restore: " + url); // NOI18N } } }
FileObject fo = fs.findResource(res); File file2Fo = (fo != null) ? findFileInRepository(fo) : null;
/** * Returns {@code FileObject} from the NetBeans default (system, configuration) * filesystem or {@code null} if does not exist. * If you wish to create the file/folder when it does not already exist, * start with {@link #getConfigRoot} and use {@link #createData(FileObject, String)} * or {@link #createFolder(FileObject, String)} methods. * @param path the path from the root of the NetBeans default (system, configuration) * filesystem delimited by '/' or empty string to get root folder. * @throws NullPointerException if the path is {@code null} * @return a {@code FileObject} for given path in the NetBeans default (system, configuration) * filesystem or {@code null} if does not exist * @since org.openide.filesystems 7.19 */ @SuppressWarnings("deprecation") public static FileObject getConfigFile(String path) { Parameters.notNull("path", path); //NOI18N return Repository.getDefault().getDefaultFileSystem().findResource(path); }
/** Finds the right file. */ public Object readResolve() { Repository rep = Repository.getDefault(); @SuppressWarnings("deprecation") // FileSystem.systemName historical part of serial form FileSystem fs = rep.findFileSystem(fsName); FileObject fo = null; if (fs != null) { // scan desired system fo = fs.findResource(fileName); } if (fo == null) { // create invalid file instead return new Invalid(fsName, fileName); } return fo; } }
return Collections.emptyList(); FileObject writableFolder = writable.findResource(path); continue; FileObject hiddenFo = systems[i].findResource(p); if (hiddenFo != null) { if (result == null) {
String orig = (String) files.next(); String fn = prefix + orig; FileObject obj = fo.getFileSystem().findResource(fn);
/** * Gets FileObject for passed url. * @param url * @return appropriate FileObject. Can return null for other protocol than nbfs or * if such FileObject isn't reachable via Repository. */ static FileObject getFileObject(URL url) { if (!url.getProtocol().equals(FileURL.PROTOCOL)) { return null; } if (isOldEncoding(url)) { return oldDecode(url); } String[] urlParts = split(url); String fsName = decodeFsPart(urlParts[0]); String foName = decodeFoPart(urlParts[1]); FileSystem fsys = fsName.equals(SYSTEM_FILE_SYSTEM_NAME) ? Repository.getDefault().getDefaultFileSystem() : Repository.getDefault().findFileSystem(fsName); return (fsys == null) ? null : fsys.findResource(foName); }
private static FileObject oldDecode(URL u) { String resourceName = u.getFile(); if (resourceName.startsWith("/")) resourceName = resourceName.substring(1); // NOI18N // first part is FS name int first = resourceName.indexOf('/'); // NOI18N if (first == -1) return null; String fileSystemName = oldDecodeFSName(resourceName.substring(0, first)); resourceName = resourceName.substring(first); FileSystem fsys = ExternalUtil.getRepository().findFileSystem(fileSystemName); return (fsys == null) ? null : fsys.findResource(resourceName); }
public boolean createDataObjectFor (String mimeType) { if(!isSupported(mimeType)) { return false; } FileSystem fs = Repository.getDefault ().getDefaultFileSystem (); FileObject fo = fs.findResource ("Editors/" + mimeType); if (fo == null) return false; Boolean b = (Boolean) fo.getAttribute ("createDataObject"); if (b == null) return true; return b.booleanValue (); }
private DataFolder getRecentFolder () { if (recentListFolder == null) { FileObject fo = Repository.getDefault ().getDefaultFileSystem (). findResource ("Templates/Recent"); // NOI18N if (fo != null) { recentListFolder = DataFolder.findFolder(fo); } } return recentListFolder; }
private boolean validBinary() { String validBinaryPath = getValidBinaryPath(); if (validBinaryPath != null) { FileObject fo = fileSystem.findResource(validBinaryPath); // can be null if (fo != null && fo.isValid()) { return MIMENames.isBinary(fo.getMIMEType()); } } return false; }
private FileObject findProjectCreator() { for(CompilerSet set : CompilerSetManager.get(env).getCompilerSets()) { if (set.getCompilerFlavor().isSunStudioCompiler()) { String directory = set.getDirectory(); FileObject creator = fileSystem.findResource(directory+"/../lib/ide_project/bin/ide_project"); if (creator != null && creator.isValid()) { return creator; } } } return null; }