]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/util/binary/BinaryFile.java
Merge commit '3efd7d44a55ae1fff284a1826e7c9afe27e0815e'
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / util / binary / BinaryFile.java
index 1e9dfa3fbe71ac5ac3789e4be6f3cbf94c9a0597..e7d8d386eb14c79ec6b295b215c3e3626384d642 100644 (file)
@@ -578,7 +578,41 @@ public class BinaryFile implements RandomAccessBinary, BinaryReadable, BinaryWri
 \r
 \r
        // WRITE
-               
+\r
+       void _putLong(long value) throws IOException\r
+       {\r
+               prepareForWrite(8);\r
+               int posInBuf = (int) (pointer - buf_pos);\r
+               buf[posInBuf] = (byte) (value >>> 56);\r
+               buf[posInBuf+1] = (byte) (value >>> 48);\r
+               buf[posInBuf+2] = (byte) (value >>> 40);\r
+               buf[posInBuf+3] = (byte) (value >>> 32);\r
+               buf[posInBuf+4] = (byte) (value >>> 24);\r
+               buf[posInBuf+5] = (byte) (value >>> 16);\r
+               buf[posInBuf+6] = (byte) (value >>> 8);\r
+               buf[posInBuf+7] = (byte) value;\r
+               posInBuf += 8;\r
+               pointer += 8;\r
+               if (write_buf_count<posInBuf) write_buf_count = posInBuf;\r
+               if (readable_bytes_count<write_buf_count) readable_bytes_count=write_buf_count;\r
+               if (virtualLength<pointer) virtualLength=pointer;\r
+       }\r
+\r
+       void _putInt(int value) throws IOException\r
+       {\r
+               prepareForWrite(4);\r
+               int posInBuf = (int) (pointer - buf_pos);\r
+               buf[posInBuf] = (byte) (value >>> 24);\r
+               buf[posInBuf+1] = (byte) (value >>> 16);\r
+               buf[posInBuf+2] = (byte) (value >>> 8);\r
+               buf[posInBuf+3] = (byte) value;\r
+               posInBuf += 4;\r
+               pointer += 4;\r
+               if (write_buf_count<posInBuf) write_buf_count = posInBuf;\r
+               if (readable_bytes_count<write_buf_count) readable_bytes_count=write_buf_count;\r
+               if (virtualLength<pointer) virtualLength=pointer;\r
+       }\r
+
        void _put(int value) throws IOException
        {
                prepareForWrite(1);
@@ -666,22 +700,12 @@ public class BinaryFile implements RandomAccessBinary, BinaryReadable, BinaryWri
 
        @Override
        public void writeInt(int value) throws IOException {
-               _put(value >>> 24);
-               _put(value >>> 16);
-               _put(value >>> 8);
-               _put(value);
+               _putInt(value);
        }
 
        @Override
        public void writeLong(long value) throws IOException {
-               _put((int) (value >>> 56));
-               _put((int) (value >>> 48));
-               _put((int) (value >>> 40));
-               _put((int) (value >>> 32));
-               _put((int) (value >>> 24));
-               _put((int) (value >>> 16));
-               _put((int) (value >>> 8));
-               _put((int) (value));
+               _putLong(value);
        }
 
        @Override