/** @return the default pool */ public Object readResolve() { return getDefault(); } }
/** * Executes atomic action. For more info see {@link FileSystem#runAtomicAction}. * <p> * All events about filesystem changes (related to events on all affected instances of <code>FileSystem</code>) * are postponed after the whole <code>atomicCode</code> * is executed. * </p> * @param atomicCode code that is supposed to be run as atomic action. See {@link FileSystem#runAtomicAction} * @throws java.io.IOException * @since 7.5 */ @SuppressWarnings("deprecation") public static final void runAtomicAction(final AtomicAction atomicCode) throws IOException { Repository.getDefault().getDefaultFileSystem().runAtomicAction(atomicCode); }
/** * 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); }
/** Method to call when set of URLs returned from the {@link #layers()} * method changed and there is a need to refresh it. Refresh is very likely * a time consuming task - consider invoking it on a background thread and * don't hold any locks while calling the method */ protected final void refresh() { Repository.getDefault().refreshAdditionalLayers(); } }
/** * 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 void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { getDefault().readExternal(ois); }
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 void writeObject(ObjectOutputStream oos) throws IOException { getDefault().writeExternal(oos); }
private void initCacheStore() { String userDir = System.getProperty("netbeans.user"); // NOI18N if (userDir != null) { cacheStore = new File(new File(new File (userDir, "var"), "cache"), DATA_DIRECTORY); // NOI18N } else { File cachedir = FileUtil.toFile(org.openide.filesystems.Repository.getDefault().getDefaultFileSystem().getRoot()); cacheStore = new File(cachedir, DATA_DIRECTORY); } cacheStore.mkdirs(); } }
/** Allows subclasses registered as {@link Repository#getDefault()} to * find out list of URLs for a given provider. The method just calls * {@link LayerProvider#registerLayers(java.util.Collection)}. * * @param p the provider. * @return ordered list of URLs * @since 7.59 */ protected final List<? extends URL> findLayers(LayerProvider p) { if (this != Repository.getDefault()) { return Collections.emptyList(); } List<URL> urls = new ArrayList<URL>(); p.registerLayers(urls); return urls; }
protected FileObject findPrimaryFile (FileObject fo) { FileSystem fs = null; try { fs = fo.getFileSystem (); } catch (FileStateInvalidException e) { return null; } if (fs != Repository.getDefault ().getDefaultFileSystem ()) { return null; } return super.findPrimaryFile (fo); }
private static JarFileSystem findJarFileSystem(File jarFile) { JarFileSystem retVal = null; @SuppressWarnings("deprecation") // keep for backward compatibility w/ NB 3.x Enumeration<? extends FileSystem> en = Repository.getDefault().getFileSystems(); while (en.hasMoreElements()) { FileSystem fs = en.nextElement(); if (fs instanceof JarFileSystem) { File fsJarFile = ((JarFileSystem) fs).getJarFile(); if (fsJarFile.equals(jarFile)) { retVal = (JarFileSystem) fs; break; } } } return retVal; }
private static URL recreateURL(String fileName, String fileSystem, FileSystem fs) throws IOException { if (fileSystem == null) { return createURL(fs, fileName); } else if (fileSystem.equals("SystemFileSystem")) { return createURL(Repository.getDefault().getDefaultFileSystem(), fileName); } else { // Does not work. No FS is mounted anymore. throw new java.io.FileNotFoundException (fileName+" "+fileSystem); //NOI18N } } private static URL createURL(FileSystem fs, String fileName) throws IOException {
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); }
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 (); }
/** All filesystems that are capable of this capability. * @return enumeration of FileSystems that satifies this capability * @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 FileSystem> fileSystems() { class FFS implements org.openide.util.Enumerations.Processor<FileSystem, FileSystem> { @Deprecated public FileSystem process(FileSystem fs, Collection<FileSystem> ignore) { return fs.getCapability().capableOf(FileSystemCapability.this) ? fs : null; } } return org.openide.util.Enumerations.filter(Repository.getDefault().fileSystems(), new FFS()); }
private static String getBundleName(Language l) { FileSystem fs = Repository.getDefault().getDefaultFileSystem(); FileObject root = fs.findResource("Editors/" + l.getMimeType()); // NOI18N Object attrValue = root.getAttribute("SystemFileSystem.localizingBundle"); //NOI18N // [PENDING] if (bundleName == null) ... check for bundle name in nbs file return (String) attrValue; }
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 } } }
Enumeration<? extends FileSystem> en = Repository.getDefault().getFileSystems(); LinkedList<FileObject> list = new LinkedList<FileObject>(); String fileName = f.getAbsolutePath();
/** 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; } }