/* * Copyright (C) 2004-2012 Geometer Plus * * 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 2 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #ifndef __OLESTORAGE_H__ #define __OLESTORAGE_H__ #include #include #include #include struct OleEntry { enum Type { DIR = 1, STREAM = 2, ROOT_DIR = 5, LOCK_BYTES =3 }; typedef std::vector Blocks; std::string name; unsigned int length; Type type; Blocks blocks; bool isBigBlock; }; class OleStorage { public: static const std::size_t BBD_BLOCK_SIZE; public: OleStorage(); bool init(shared_ptr, std::size_t streamSize); void clear(); const std::vector &getEntries() const; bool getEntryByName(std::string name, OleEntry &entry) const; unsigned int getSectorSize() const; unsigned int getShortSectorSize() const; public: //TODO make private bool countFileOffsetOfBlock(const OleEntry &e, unsigned int blockNumber, unsigned int &result) const; private: bool readDIFAT(char *oleBuf); bool readBBD(char *oleBuf); bool readSBD(char *oleBuf); bool readProperties(char *oleBuf); bool readAllEntries(); bool readOleEntry(int propNumber, OleEntry &entry); private: shared_ptr myInputStream; unsigned int mySectorSize, myShortSectorSize; std::size_t myStreamSize; std::vector myDIFAT; //double-indirect file allocation table std::vector myBBD; //Big Block Depot std::vector mySBD; //Small Block Depot std::vector myProperties; std::vector myEntries; int myRootEntryIndex; }; inline const std::vector &OleStorage::getEntries() const { return myEntries; } inline unsigned int OleStorage::getSectorSize() const { return mySectorSize; } inline unsigned int OleStorage::getShortSectorSize() const { return myShortSectorSize; } #endif /* __OLESTORAGE_H__ */