|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacore; import java.io.File; import java.util.LinkedHashSet; import java.util.Set; import org.netbeans.modules.javacore.internalapi.JavaMetamodel; import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileUtil; /** * * @author Jan Becicka */ public class Util { //copy - paste programming //http://ant.netbeans.org/source/browse/ant/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java.diff?r1=1.15&r2=1.16 //http:/java.netbeans.org/source/browse/java/javacore/src/org/netbeans/modules/javacore/Util.java //http://core.netbeans.org/source/browse/core/ui/src/org/netbeans/core/ui/MenuWarmUpTask.java //http://core.netbeans.org/source/browse/core/src/org/netbeans/core/actions/RefreshAllFilesystemsAction.java //http://java.netbeans.org/source/browse/java/api/src/org/netbeans/api/java/classpath/ClassPath.java private static FileSystem[] fileSystems; private static FileSystem[] getFileSystems() { if (fileSystems != null) { return fileSystems; } File[] roots = File.listRoots(); Set allRoots = new LinkedHashSet(); assert roots != null && roots.length > 0 : "Could not list file roots"; // NOI18N for (int i = 0; i < roots.length; i++) { File root = roots[i]; FileObject random = FileUtil.toFileObject(root); if (random == null) continue; FileSystem fs; try { fs = random.getFileSystem(); allRoots.add(fs); /*Because there is MasterFileSystem impl. that provides conversion to FileObject for all File.listRoots (except floppy drives and empty CD). Then there is useless to convert all roots into FileObjects including net drives that might cause performance regression. */ if (fs != null) { break; } } catch (FileStateInvalidException e) { throw new AssertionError(e); } } FileSystem[] retVal = new FileSystem [allRoots.size()]; allRoots.toArray(retVal); assert retVal.length > 0 : "Could not get any filesystem"; // NOI18N return fileSystems = retVal; } /** * Adds given listener to all FileSystems * @param l listener to add */ public static void addFileSystemsListener(FileChangeListener l) { FileSystem[] fileSystems = getFileSystems(); for (int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.