/** * 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); }
/** 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()); }
if (newRepo == null) { newRepo = new Repository(new MainFS()); newRepo.addFileSystemImpl(addLater[0]);
/** 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(); } }
private void writeObject(ObjectOutputStream oos) throws IOException { getDefault().writeExternal(oos); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { getDefault().readExternal(ois); }
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 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); }
/** * 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); }
/** Methods that tells {@link Repository} subclasses to refresh list of * URLs provided by {@link LayerProvider}s. * @since 7.59 */ protected void refreshAdditionalLayers() { if (getDefaultFileSystem() instanceof MainFS) { ((MainFS)getDefaultFileSystem()).refreshLayers(); } }
Enumeration<? extends FileSystem> ee = getFileSystems(); FileSystem fs; removeFileSystem(fs); init(); addFileSystem((FileSystem) iter.next());
/** @return the default pool */ public Object readResolve() { return getDefault(); } }
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); }
/** All filesystems that are capable of this capability. * @return enumeration of FileSystems that satifies this capability * @deprecated Please use the <a href="@JAVA/API@/org/netbeans/api/java/classpath/api.html">ClassPath API</a> instead. */ public Enumeration fileSystems () { class FFS implements org.openide.util.Enumerations.Processor { public Object process (Object obj, Collection ignore) { FileSystem fs = (FileSystem)obj; return fs.getCapability().capableOf(FileSystemCapability.this) ? fs : null; } } return org.openide.util.Enumerations.filter ( ExternalUtil.getRepository ().fileSystems (), new FFS () ); }
/** Initialazes the pool. */ private void init() { // empties the pool fileSystems = new ArrayList<FileSystem>(); names = new Hashtable<String, FileSystem>(); if (addFileSystemDelayed(system)) { addFileSystem(system); } }
/** Adds new filesystem to the pool. * <em>Note</em> that a filesystem cannot be assigned to more than one file * system pool at one time (though currently there is only one pool anyway). * At any given time, no two filesystems in the pool may share the same {@link FileSystem#getSystemName name} * (unless all but one are {@link FileSystem#isValid invalid}). To be sure, that * filesystem was really added in Repository, then test that <code>FileSystem</code> * is valid. * @param fs filesystem to add * @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 void addFileSystem(FileSystem fs) { boolean fireIt; synchronized (this) { fireIt = addFileSystemImpl(fs); } // postponed firing after synchronized block to prevent deadlock if (fireIt) { fireFileSystem(fs, true); } }
/** Initialazes the pool. */ private void init () { // empties the pool fileSystems = new ArrayList (); names = new Hashtable (); addFileSystem (system); }
/** * @param rep may be null */ private static synchronized void setRepository (Repository rep) { repository = rep; if (repository == null) { // if not provided use default one repository = new Repository (FileUtil.createMemoryFileSystem ()); } }
Enumeration<? extends FileSystem> en = Repository.getDefault().getFileSystems(); LinkedList<FileObject> list = new LinkedList<FileObject>(); String fileName = f.getAbsolutePath();