Search in sources :

Example 1 with JarFileSystem

use of org.openide.filesystems.JarFileSystem in project enclojure by EricThorsen.

the class SourcePathProviderImpl method getRoot.

/**
 * Returns source root for given ClassPath root as String, or <code>null</code>.
 */
private static String getRoot(FileObject fileObject) {
    File f = null;
    String path = "";
    try {
        if (fileObject.getFileSystem() instanceof JarFileSystem) {
            f = ((JarFileSystem) fileObject.getFileSystem()).getJarFile();
            if (!fileObject.isRoot()) {
                path = "!/" + fileObject.getPath();
            }
        } else {
            f = FileUtil.toFile(fileObject);
        }
    } catch (FileStateInvalidException ex) {
    }
    if (f != null) {
        return f.getAbsolutePath() + path;
    } else {
        return null;
    }
}
Also used : JarFileSystem(org.openide.filesystems.JarFileSystem) FileStateInvalidException(org.openide.filesystems.FileStateInvalidException) File(java.io.File)

Aggregations

File (java.io.File)1 FileStateInvalidException (org.openide.filesystems.FileStateInvalidException)1 JarFileSystem (org.openide.filesystems.JarFileSystem)1