From: <ha...@us...> - 2010-04-23 13:00:25
|
Revision: 12909 http://jmol.svn.sourceforge.net/jmol/?rev=12909&view=rev Author: hansonr Date: 2010-04-23 13:00:18 +0000 (Fri, 23 Apr 2010) Log Message: ----------- version=12.0.RC8_dev # bug fix: binary document reader may not read full set of bytes in byte array when using http: Modified Paths: -------------- trunk/Jmol/src/org/jmol/jvxl/readers/Dns6BinaryReader.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/util/BinaryDocument.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/jvxl/readers/Dns6BinaryReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/Dns6BinaryReader.java 2010-04-22 19:18:46 UTC (rev 12908) +++ trunk/Jmol/src/org/jmol/jvxl/readers/Dns6BinaryReader.java 2010-04-23 13:00:18 UTC (rev 12909) @@ -200,6 +200,7 @@ binarydoc.readByteArray(brickLayer); pt = 0; nBytes = binarydoc.getPosition(); + System.out.println("DNs6B reader: " + nBytes); } private float getBrickValue(int pt) { Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-04-22 19:18:46 UTC (rev 12908) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2010-04-23 13:00:18 UTC (rev 12909) @@ -14158,6 +14158,7 @@ propertyName = "cutoff"; propertyValue = new Float(floatParameter(i)); } + ptCutoff = i; break; case Token.downsample: propertyName = "downsample"; Modified: trunk/Jmol/src/org/jmol/util/BinaryDocument.java =================================================================== --- trunk/Jmol/src/org/jmol/util/BinaryDocument.java 2010-04-22 19:18:46 UTC (rev 12908) +++ trunk/Jmol/src/org/jmol/util/BinaryDocument.java 2010-04-23 13:00:18 UTC (rev 12909) @@ -98,24 +98,30 @@ return b; } - public int readByteArray(byte[] b) throws IOException { - int n = ioRead(b); - nBytes += n; - return n; + public void readByteArray(byte[] b) throws Exception { + readByteArray(b, 0, b.length); } - private int ioRead(byte[] b) throws IOException { - int n = stream.read(b); - if (n > 0 && os != null) - os.write(b, 0, n); - return n; + public int readByteArray(byte[] b, int off, int len) throws Exception { + int n = ioRead(b, off, len); + if (n > 0) + nBytes += n; + int nBytesRead = n; + if (n > 0 && n < b.length) { + // apparently this is possible over the web + // it occurred in getting a DNS6B format file from Uppsala + while (nBytesRead < b.length && n > 0) { + n = ioRead(b, nBytesRead, b.length - nBytesRead); + if (n > 0) { + nBytes += n; + nBytesRead += n; + } + } + } + return nBytesRead; } - public void readByteArray(byte[] b, int off, int len) throws Exception { - nBytes += ioRead(b, off, len); - } - - private long ioRead(byte[] b, int off, int len) throws Exception { + private int ioRead(byte[] b, int off, int len) throws Exception { int n = stream.read(b, off, len); if (n > 0 && os != null) os.write(b, off, n); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-04-22 19:18:46 UTC (rev 12908) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2010-04-23 13:00:18 UTC (rev 12909) @@ -3,6 +3,7 @@ version=12.0.RC8_dev +# bug fix: binary document reader may not read full set of bytes in byte array when using http: # -------------------------------------------------------------- #version=12.0.RC7 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |