-/* $RCSfile$\r
- * $Author$\r
- * $Date$\r
- * $Revision$\r
- *\r
- * Copyright (C) 2011 The Jmol Development Team\r
- *\r
- * Contact: jmol-developers@lists.sf.net\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
- * 02110-1301, USA.\r
- */\r
-\r
-package javajs.util;\r
-\r
-\r
-class CompoundDocHeader {\r
-\r
- /**\r
- * \r
- */\r
- private final CompoundDocument cd;\r
-\r
- /**\r
- * @param compoundDocument\r
- */\r
- CompoundDocHeader(CompoundDocument compoundDocument) {\r
- cd = compoundDocument;\r
- }\r
-\r
- //512 bytes\r
- //offset 0:\r
- byte[] magicNumbers = new byte[8]; // D0CF11E0A1B11AE1\r
- byte[] uniqueID16 = new byte[16];\r
- byte revNumber; // 3E = 62\r
- //byte unusedb1;\r
- byte verNumber; // 3\r
- //byte unusedb2;\r
- //short byteOrder; // -2 littleEndian\r
- short sectorPower; // 2^sectorPower = sector size; 512 = 2^9\r
- short shortSectorPower; // 2^shortSectorPower = short sector size; 64 = 2^6\r
- byte[] unused = new byte[10];\r
- int nSATsectors; // number of sectors for sector allocation table\r
- int SID_DIR_start; // sector identifier of start of directory sector\r
- //offset 56:\r
- int minBytesStandardStream; // less than this (and not DIR) will be "short"\r
- int SID_SSAT_start; // start of short sector allocation table (SSAT)\r
- int nSSATsectors; // number of sectors allocated to SSAT\r
- int SID_MSAT_next; // pointer to next master sector allocation table sector\r
- int nAdditionalMATsectors; // number of sectors allocated to more MSAT sectors\r
- //offset 76; 436 bytes: \r
- int[] MSAT0 = new int[109]; // beginning of master allocation table \r
-\r
- /*\r
- * Sector 0 is first sector AFTER this header\r
- * \r
- * If sectorPower = 9, then this allows for 109 PAGES\r
- * of sector allocation tables, with 127 pointers per\r
- * page (plus 1 pointer to the next SAT page), each \r
- * pointing to a sector of 512 bytes. Thus, with no additional\r
- * MSAT pages, the header allows for 109*128*512 = 7.1 Mb file\r
- * \r
- */\r
-\r
- final boolean readData() {\r
- try {\r
- cd.readByteArray(magicNumbers, 0, 8);\r
- if (magicNumbers[0] != (byte) 0xD0 || magicNumbers[1] != (byte) 0xCF\r
- || magicNumbers[2] != (byte) 0x11 || magicNumbers[3] != (byte) 0xE0\r
- || magicNumbers[4] != (byte) 0xA1 || magicNumbers[5] != (byte) 0xB1\r
- || magicNumbers[6] != (byte) 0x1A || magicNumbers[7] != (byte) 0xE1)\r
- return false;\r
- cd.readByteArray(uniqueID16, 0, 16);\r
- revNumber = cd.readByte();\r
- cd.readByte();\r
- verNumber = cd.readByte();\r
- cd.readByte();\r
- byte b1 = cd.readByte();\r
- byte b2 = cd.readByte();\r
- cd.isBigEndian = (b1 == -1 && b2 == -2);\r
- sectorPower = cd.readShort();\r
- shortSectorPower = cd.readShort();\r
- cd.readByteArray(unused, 0, 10);\r
- nSATsectors = cd.readInt();\r
- SID_DIR_start = cd.readInt();\r
- cd.readByteArray(unused, 0, 4);\r
- minBytesStandardStream = cd.readInt();\r
- SID_SSAT_start = cd.readInt();\r
- nSSATsectors = cd.readInt();\r
- SID_MSAT_next = cd.readInt();\r
- nAdditionalMATsectors = cd.readInt();\r
- for (int i = 0; i < 109; i++)\r
- MSAT0[i] = cd.readInt();\r
- } catch (Exception e) {\r
- System.out.println(e.toString());\r
- return false;\r
- }\r
- return true;\r
- }\r
+/* $RCSfile$
+ * $Author$
+ * $Date$
+ * $Revision$
+ *
+ * Copyright (C) 2011 The Jmol Development Team
+ *
+ * Contact: jmol-developers@lists.sf.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+package javajs.util;
+
+
+class CompoundDocHeader {
+
+ /**
+ *
+ */
+ private final CompoundDocument cd;
+
+ /**
+ * @param compoundDocument
+ */
+ CompoundDocHeader(CompoundDocument compoundDocument) {
+ cd = compoundDocument;
+ }
+
+ //512 bytes
+ //offset 0:
+ byte[] magicNumbers = new byte[8]; // D0CF11E0A1B11AE1
+ byte[] uniqueID16 = new byte[16];
+ byte revNumber; // 3E = 62
+ //byte unusedb1;
+ byte verNumber; // 3
+ //byte unusedb2;
+ //short byteOrder; // -2 littleEndian
+ short sectorPower; // 2^sectorPower = sector size; 512 = 2^9
+ short shortSectorPower; // 2^shortSectorPower = short sector size; 64 = 2^6
+ byte[] unused = new byte[10];
+ int nSATsectors; // number of sectors for sector allocation table
+ int SID_DIR_start; // sector identifier of start of directory sector
+ //offset 56:
+ int minBytesStandardStream; // less than this (and not DIR) will be "short"
+ int SID_SSAT_start; // start of short sector allocation table (SSAT)
+ int nSSATsectors; // number of sectors allocated to SSAT
+ int SID_MSAT_next; // pointer to next master sector allocation table sector
+ int nAdditionalMATsectors; // number of sectors allocated to more MSAT sectors
+ //offset 76; 436 bytes:
+ int[] MSAT0 = new int[109]; // beginning of master allocation table
+
+ /*
+ * Sector 0 is first sector AFTER this header
+ *
+ * If sectorPower = 9, then this allows for 109 PAGES
+ * of sector allocation tables, with 127 pointers per
+ * page (plus 1 pointer to the next SAT page), each
+ * pointing to a sector of 512 bytes. Thus, with no additional
+ * MSAT pages, the header allows for 109*128*512 = 7.1 Mb file
+ *
+ */
+
+ final boolean readData() {
+ try {
+ cd.readByteArray(magicNumbers, 0, 8);
+ if (magicNumbers[0] != (byte) 0xD0 || magicNumbers[1] != (byte) 0xCF
+ || magicNumbers[2] != (byte) 0x11 || magicNumbers[3] != (byte) 0xE0
+ || magicNumbers[4] != (byte) 0xA1 || magicNumbers[5] != (byte) 0xB1
+ || magicNumbers[6] != (byte) 0x1A || magicNumbers[7] != (byte) 0xE1)
+ return false;
+ cd.readByteArray(uniqueID16, 0, 16);
+ revNumber = cd.readByte();
+ cd.readByte();
+ verNumber = cd.readByte();
+ cd.readByte();
+ byte b1 = cd.readByte();
+ byte b2 = cd.readByte();
+ cd.isBigEndian = (b1 == -1 && b2 == -2);
+ sectorPower = cd.readShort();
+ shortSectorPower = cd.readShort();
+ cd.readByteArray(unused, 0, 10);
+ nSATsectors = cd.readInt();
+ SID_DIR_start = cd.readInt();
+ cd.readByteArray(unused, 0, 4);
+ minBytesStandardStream = cd.readInt();
+ SID_SSAT_start = cd.readInt();
+ nSSATsectors = cd.readInt();
+ SID_MSAT_next = cd.readInt();
+ nAdditionalMATsectors = cd.readInt();
+ for (int i = 0; i < 109; i++)
+ MSAT0[i] = cd.readInt();
+ } catch (Exception e) {
+ System.out.println(e.toString());
+ return false;
+ }
+ return true;
+ }
}
\ No newline at end of file