6 * Some portions of this file have been modified by Robert Hanson hansonr.at.stolaf.edu 2012-2017
7 * for use in SwingJS via transpilation into JavaScript using Java2Script.
9 * Copyright (C) 2011 The Jmol Development Team
11 * Contact: jmol-developers@lists.sf.net
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 class CompoundDocHeader {
37 private final CompoundDocument cd;
40 * @param compoundDocument
42 CompoundDocHeader(CompoundDocument compoundDocument) {
43 cd = compoundDocument;
48 byte[] magicNumbers = new byte[8]; // D0CF11E0A1B11AE1
49 byte[] uniqueID16 = new byte[16];
50 byte revNumber; // 3E = 62
54 //short byteOrder; // -2 littleEndian
55 short sectorPower; // 2^sectorPower = sector size; 512 = 2^9
56 short shortSectorPower; // 2^shortSectorPower = short sector size; 64 = 2^6
57 byte[] unused = new byte[10];
58 int nSATsectors; // number of sectors for sector allocation table
59 int SID_DIR_start; // sector identifier of start of directory sector
61 int minBytesStandardStream; // less than this (and not DIR) will be "short"
62 int SID_SSAT_start; // start of short sector allocation table (SSAT)
63 int nSSATsectors; // number of sectors allocated to SSAT
64 int SID_MSAT_next; // pointer to next master sector allocation table sector
65 int nAdditionalMATsectors; // number of sectors allocated to more MSAT sectors
66 //offset 76; 436 bytes:
67 int[] MSAT0 = new int[109]; // beginning of master allocation table
70 * Sector 0 is first sector AFTER this header
72 * If sectorPower = 9, then this allows for 109 PAGES
73 * of sector allocation tables, with 127 pointers per
74 * page (plus 1 pointer to the next SAT page), each
75 * pointing to a sector of 512 bytes. Thus, with no additional
76 * MSAT pages, the header allows for 109*128*512 = 7.1 Mb file
80 final boolean readData() {
82 cd.readByteArray(magicNumbers, 0, 8);
83 if ((magicNumbers[0] & 0xFF) != 0xD0 || (magicNumbers[1] & 0xFF) != 0xCF
84 || (magicNumbers[2] & 0xFF) != 0x11 || (magicNumbers[3] & 0xFF) != 0xE0
85 || (magicNumbers[4] & 0xFF) != 0xA1 || (magicNumbers[5] & 0xFF) != 0xB1
86 || (magicNumbers[6] & 0xFF) != 0x1A || (magicNumbers[7] & 0xFF) != 0xE1)
88 cd.readByteArray(uniqueID16, 0, 16);
89 revNumber = cd.readByte();
91 verNumber = cd.readByte();
93 byte b1 = cd.readByte();
94 byte b2 = cd.readByte();
95 cd.isBigEndian = (b1 == -1 && b2 == -2);
96 sectorPower = cd.readShort();
97 shortSectorPower = cd.readShort();
98 cd.readByteArray(unused, 0, 10);
99 nSATsectors = cd.readInt();
100 SID_DIR_start = cd.readInt();
101 cd.readByteArray(unused, 0, 4);
102 minBytesStandardStream = cd.readInt();
103 SID_SSAT_start = cd.readInt();
104 nSSATsectors = cd.readInt();
105 SID_MSAT_next = cd.readInt();
106 nAdditionalMATsectors = cd.readInt();
107 for (int i = 0; i < 109; i++)
108 MSAT0[i] = cd.readInt();
109 } catch (Exception e) {
110 System.out.println(e.toString());