@SuppressWarnings("deprecation")
    @Override
    public File getFile(String path, boolean nativeCode) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " asked to getFile for path " + path);

        path = preSlashify(path);
        if (path.equals("/")) {
            // return a file for "/" .. for normal bundles this would be the jar
            // or directory. For loose, we might have a dir mapped to root, or may not
            // if we do, we'll try using it.
            if (container.getPhysicalPath() != null)
                return new File(container.getPhysicalPath());
            else
                return null;
        }
        final Entry entry = container.getEntry(path);
        if (entry == null) {
            //no entry found for path, bundle has been asked for a file/path that doesn't exist.
            //can happen via bundle-classpath entries for paths that don't exist in the bundle.
            return null;
        }
        Container entryContainer = getContainer(entry);
        if (entryContainer == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, " returning file for entry at " + path + " @ " + entry.getPhysicalPath());

            // this is a 'normal entry' we are going to assume we can get a real file
            // we are allowed to use getPhysicalPath, as this layer has to see through the abstraction for
            // leaf nodes that are files.
            final String physical = entry.getPhysicalPath();
            if (physical != null) {
                return AccessController.doPrivileged(new PrivilegedAction<File>() {
                    @Override
                    public File run() {
                        return new File(physical);
                    }

                });
            }
            // TODO Going to have to extract the content out to a file on disk

            // This would be a case where an entry in a container has no physical path. 
            // If loose config allowed jars to be mapped as directories, this would occur there.

            // Jars mapped as files are already handled by equinox natively, so the lack of 
            // physical paths there will not cause issues.

            // The other common source of imaginary physical paths is intermediate directory 
            // creation..  
            // (eg, mapping /etc/fred.txt as /etc/fish/goat/horse/fred.txt and asking for physical path of 'goat')

            // Current artifact implementations always have a physical path, but this may not remain true 
            // forever, so this case DOES need to be handled, else we'll have some very entertaining 
            // bugs to handle for future deployment types. 
            return null;
        }

        if (nativeCode) {
            // native code is not supported as a container
            return null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " entry was a container.. but was it root? " + entryContainer.isRoot());
        if (!entryContainer.isRoot()) {
            // If the container is not a root then it is 
            // a simple directory in an archive; just return null.
            // The framework will handle nested directories in archives
            return null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " leaf node was a root container, so use marker file for equinox");

        // This is a root container and may be on the bundle classpath.
        // Need to create a temp file to return so we can find this container later when a bundle file is created
        final File tempBase = context.getDataFile("nestedTempFiles");
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, " creating a temp dir, request was for " + path + " the nested path");

        // create the temp dir, if needed.. not clear
        if (!AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
            @Override
            public Boolean run() {
                return tempBase.exists() || tempBase.mkdirs();
            }
        })) {
            //no chained exception will mean mkdirs failed.
            throw new IllegalStateException();
        }
        try {
            File t = null;
            try {
                t = AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
                    @Override
                    public File run() throws IOException {
                        return File.createTempFile(entry.getName(), null, tempBase);
                    }
                });
            } catch (PrivilegedActionException e) {
                Exception e2 = e.getException();
                if (e2 instanceof IOException)
                    throw (IOException) e2;
                if (e2 instanceof RuntimeException)
                    throw (RuntimeException) e2;
                throw new UndeclaredThrowableException(e);
            }
            final File tempKey = t;

            // Add it to the nestedFiles map so that the ModuleBundleFileFactory impl can
            // find the container if the framework attempts to create a bundle file from it.
            nestedFiles.put(tempKey, entryContainer);
            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                @Override
                public Object run() {
                    tempKey.deleteOnExit();
                    return null;
                }
            });

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, " returning a tempkey file.. " + tempKey.getAbsolutePath());
            return tempKey;
        } catch (IOException e) {
            //chained exception will mean the temp create failed.
            throw new IllegalStateException(e);
        }
    }
@ SuppressWarnings ( "deprecation" ) @ Override public File getFile ( String path , boolean nativeCode ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , " asked to getFile for path " + path ) ; path = preSlashify ( path ) ; if ( path . equals ( "/" ) ) { if ( container . getPhysicalPath ( ) != null ) return new File ( container . getPhysicalPath ( ) ) ; else return null ; } final Entry entry = container . getEntry ( path ) ; if ( entry == null ) { return null ; } Container entryContainer = getContainer ( entry ) ; if ( entryContainer == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , " returning file for entry at " + path + " @ " + entry . getPhysicalPath ( ) ) ; final String physical = entry . getPhysicalPath ( ) ; if ( physical != null ) { return AccessController . doPrivileged ( new PrivilegedAction < File > ( ) { @ Override public File run ( ) { return new File ( physical ) ; } } ) ; } return null ; } if ( nativeCode ) { return null ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , " entry was a container.. but was it root? " + entryContainer . isRoot ( ) ) ; if ( ! entryContainer . isRoot ( ) ) { return null ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , " leaf node was a root container, so use marker file for equinox" ) ; final File tempBase = context . getDataFile ( "nestedTempFiles" ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , " creating a temp dir, request was for " + path + " the nested path" ) ; if ( ! AccessController . doPrivileged ( new PrivilegedAction < Boolean > ( ) { @ Override public Boolean run ( ) { return tempBase . exists ( ) || tempBase . mkdirs ( ) ; } } ) ) { throw new IllegalStateException ( ) ; } try { File t = null ; try { t = AccessController . doPrivileged ( new PrivilegedExceptionAction < File > ( ) { @ Override public File run ( ) throws IOException { return File . createTempFile ( entry . getName ( ) , null , tempBase ) ; } } ) ; } catch ( PrivilegedActionException e ) { Exception e2 = e . getException ( ) ; if ( e2 instanceof IOException ) throw ( IOException ) e2 ; if ( e2 instanceof RuntimeException ) throw ( RuntimeException ) e2 ; throw new UndeclaredThrowableException ( e ) ; } final File tempKey = t ; nestedFiles . put ( tempKey , entryContainer ) ; AccessController . doPrivileged ( new PrivilegedAction < Object > ( ) { @ Override public Object run ( ) { tempKey . deleteOnExit ( ) ; return null ; } } ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , " returning a tempkey file.. " + tempKey . getAbsolutePath ( ) ) ; return tempKey ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } }
/*
(non-Javadoc)

@see org.eclipse.osgi.baseadaptor.bundlefile.BundleFile#getFile(java.lang.String, boolean)