Package ole

Source Code of ole.MiniFat

package ole;

import pptViewer.PptException;

/**
* File Allocation Table für den Mini-Stream
* @author Michael Roth <michi.ro@gmx.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*/
public class MiniFat extends StreamReader {
 
  private OleFile file;
  int sectorsPerFat;
  int fatPerDif;

  public MiniFat(OleFile oleFile) {
    super (oleFile, oleFile.getHeader().getSecMiniFatStart());
    this.file = oleFile;
    sectorsPerFat=this.file.getHeader().getSecSize()/4;
    fatPerDif=this.file.getHeader().getSecSize()/4-1;
  }
 
  /**
   * Eintrag in der FAT zu dem gesuchten Sektor
   * @param block Der aktuelle Sektor
   * @return Position des nachfolgenden Sektors
   * @throws PptException Falls die Sektorkette mit dem aktuellen Block endet
   */
  public int getNextBlock(int block) throws PptException {
    byte[] data;
   
    //System.out.println("Looking for next block for "+block);
   
    data = this.get(block*4, 4);
    int sector= (data[0]& 0x0FF)|((data[1]& 0x0FF)<<8)|((data[2]& 0x0FF)<<16)|((data[3]& 0x0FF)<<24);
   
    if (sector == OleFile.ENDOFCHAIN) throw new PptException("EndOfChain");
    if (sector == OleFile.DIFSECT) throw new PptException("DifSector");
    if (sector == OleFile.FATSECT) throw new PptException("FatSector");
    if (sector == OleFile.FREESECT) throw new PptException("FreeSector");

    return sector;
  }

}
TOP

Related Classes of ole.MiniFat

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.