Java Code Examples for org.openide.util.BaseUtilities#isUnix()

The following examples show how to use org.openide.util.BaseUtilities#isUnix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUtilTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testToFileObjectSlash() throws Exception { // #98388
    if (!BaseUtilities.isUnix()) {
        return;
    }
    File root = new File("/");
    assertTrue(root.isDirectory());
    LocalFileSystem lfs = new LocalFileSystem();
    lfs.setRootDirectory(root);
    final FileObject LFS_ROOT = lfs.getRoot();
    MockLookup.setInstances(new URLMapper() {
        public URL getURL(FileObject fo, int type) {
            return null;
        }
        public FileObject[] getFileObjects(URL url) {
            if (url.toExternalForm().equals("file:/")) {
                return new FileObject[] {LFS_ROOT};
            } else {
                return null;
            }
        }
    });
    URLMapper.reset();
    assertEquals(LFS_ROOT, FileUtil.toFileObject(root));
}
 
Example 2
Source File: CoreBridge.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Define {@code org.openide.modules.os.*} tokens according to the current platform.
 * @param provides a collection that may be added to
 */
public static void defineOsTokens(Collection<? super String> provides) {
    if (BaseUtilities.isUnix()) {
        provides.add("org.openide.modules.os.Unix"); // NOI18N
        if (!BaseUtilities.isMac()) {
            provides.add("org.openide.modules.os.PlainUnix"); // NOI18N
        }
    }
    if (BaseUtilities.isWindows()) {
        provides.add("org.openide.modules.os.Windows"); // NOI18N
    }
    if (BaseUtilities.isMac()) {
        provides.add("org.openide.modules.os.MacOSX"); // NOI18N
    }
    if ((BaseUtilities.getOperatingSystem() & BaseUtilities.OS_OS2) != 0) {
        provides.add("org.openide.modules.os.OS2"); // NOI18N
    }
    if ((BaseUtilities.getOperatingSystem() & BaseUtilities.OS_LINUX) != 0) {
        provides.add("org.openide.modules.os.Linux"); // NOI18N
    }
    if ((BaseUtilities.getOperatingSystem() & BaseUtilities.OS_SOLARIS) != 0) {
        provides.add("org.openide.modules.os.Solaris"); // NOI18N
    }
    
    if (isJavaFX(new File(System.getProperty("java.home")))) {
        provides.add("org.openide.modules.jre.JavaFX"); // NOI18N
    }
}
 
Example 3
Source File: FileBasedFileSystem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static FileObject getFileObject(final File file, FileObjectFactory.Caller caller) {
    FileObjectFactory fs = FileObjectFactory.getInstance(file);
    FileObject retval = null;
    if (fs != null) {
        if (file.getParentFile() == null && BaseUtilities.isUnix()) {
            retval = FileBasedFileSystem.getInstance().getRoot();
        } else {
            retval = fs.getValidFileObject(file,caller);
        }                
    }         
    return retval;
}