Remm0021 / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

J3PFile #102

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Launch TestSceneLoading.java
2.

What is the expected output? What do you see instead?
You'll get NullPointerException

What version of the product are you using? On what operating system?
Revision 4825

Please provide any additional information below.
I suggest to do this in J3PFile.java:

   private InputStream openStream(J3PEntry entry, String name, Access access){

        try{
            InputStream entryChan = requestRange(entry.offset, entry.length);
            if ((entry.flags & J3PEntry.LZMA_COMPRESSED) != 0){
                // wrap with LZMA decomressor
                return new LzmaInputStream(entryChan);
            }else{
                return entryChan;
            }
        } catch (IOException ex){
            logger.log(Level.SEVERE, "Failed to open stream: " + name, ex);
        }

        return null;
    }
    private InputStream requestRange(long offset, long length){
        try{
            ByteBuffer bb = ByteBuffer.allocateDirect((int) length);
            channel.read(bb, offset);
            bb.clear();
            ReadableBufferChannel entryChan = new ReadableBufferChannel(bb);

            InputStream in =
java.nio.channels.Channels.newInputStream(entryChan);
            return in;
        }catch (IOException ex){
            logger.log(Level.SEVERE, "Failed to open URL: ", ex);
        }

        return null;
    }

Original issue reported on code.google.com by giuseppe...@hotmail.com on 12 Feb 2010 at 4:43

GoogleCodeExporter commented 8 years ago
the j3p feature will be removed from jme3, so please refrain from using it :)

Original comment by normen667 on 12 Feb 2010 at 9:33