/* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ package org.apache.poi.poifs.filesystem; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Iterator; import java.util.List; import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.property.RootProperty; import org.apache.poi.poifs.storage.BATBlock; import org.apache.poi.poifs.storage.BATBlock.BATBlockAndIndex; import org.apache.poi.poifs.storage.HeaderBlock; /** * This class handles the MiniStream (small block store) * in the NIO case for {@link POIFSFileSystem} */ public class POIFSMiniStore extends BlockStore { private POIFSFileSystem _filesystem; private POIFSStream _mini_stream; private List _sbat_blocks; private HeaderBlock _header; private RootProperty _root; POIFSMiniStore(POIFSFileSystem filesystem, RootProperty root, List sbats, HeaderBlock header) { this._filesystem = filesystem; this._sbat_blocks = sbats; this._header = header; this._root = root; this._mini_stream = new POIFSStream(filesystem, root.getStartBlock()); } /** * Load the block at the given offset. */ protected ByteBuffer getBlockAt(final int offset) { // Which big block is this? int byteOffset = offset * POIFSConstants.SMALL_BLOCK_SIZE; int bigBlockNumber = byteOffset / _filesystem.getBigBlockSize(); int bigBlockOffset = byteOffset % _filesystem.getBigBlockSize(); // Now locate the data block for it Iterator it = _mini_stream.getBlockIterator(); for(int i=0; i bytes conversion for us _filesystem._get_property_table().getRoot().setSize(blocksUsed); } }