1*f0bc043bSIngo Weinhold // IndirectItem.h 2*f0bc043bSIngo Weinhold // 3*f0bc043bSIngo Weinhold // Copyright (c) 2003, Ingo Weinhold (bonefish@cs.tu-berlin.de) 4*f0bc043bSIngo Weinhold // 5*f0bc043bSIngo Weinhold // This program is free software; you can redistribute it and/or modify 6*f0bc043bSIngo Weinhold // it under the terms of the GNU General Public License as published by 7*f0bc043bSIngo Weinhold // the Free Software Foundation; either version 2 of the License, or 8*f0bc043bSIngo Weinhold // (at your option) any later version. 9*f0bc043bSIngo Weinhold // 10*f0bc043bSIngo Weinhold // This program is distributed in the hope that it will be useful, 11*f0bc043bSIngo Weinhold // but WITHOUT ANY WARRANTY; without even the implied warranty of 12*f0bc043bSIngo Weinhold // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*f0bc043bSIngo Weinhold // GNU General Public License for more details. 14*f0bc043bSIngo Weinhold // 15*f0bc043bSIngo Weinhold // You should have received a copy of the GNU General Public License 16*f0bc043bSIngo Weinhold // along with this program; if not, write to the Free Software 17*f0bc043bSIngo Weinhold // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18*f0bc043bSIngo Weinhold // 19*f0bc043bSIngo Weinhold // You can alternatively use *this file* under the terms of the the MIT 20*f0bc043bSIngo Weinhold // license included in this package. 21*f0bc043bSIngo Weinhold 22*f0bc043bSIngo Weinhold #ifndef INDIRECT_ITEM_H 23*f0bc043bSIngo Weinhold #define INDIRECT_ITEM_H 24*f0bc043bSIngo Weinhold 25*f0bc043bSIngo Weinhold #include "endianess.h" 26*f0bc043bSIngo Weinhold 27*f0bc043bSIngo Weinhold // IndirectItem 28*f0bc043bSIngo Weinhold /*! 29*f0bc043bSIngo Weinhold \class IndirectItem 30*f0bc043bSIngo Weinhold \brief Provides access to the on-disk indirect item structure. 31*f0bc043bSIngo Weinhold 32*f0bc043bSIngo Weinhold An indirect item lists raw blocks containing the contents of a file. 33*f0bc043bSIngo Weinhold */ 34*f0bc043bSIngo Weinhold class IndirectItem : public Item { 35*f0bc043bSIngo Weinhold public: IndirectItem()36*f0bc043bSIngo Weinhold IndirectItem() : Item() {} IndirectItem(LeafNode * node,ItemHeader * header)37*f0bc043bSIngo Weinhold IndirectItem(LeafNode *node, ItemHeader *header) 38*f0bc043bSIngo Weinhold : Item(node, header) {} 39*f0bc043bSIngo Weinhold CountBlocks()40*f0bc043bSIngo Weinhold uint32 CountBlocks() const 41*f0bc043bSIngo Weinhold { 42*f0bc043bSIngo Weinhold return GetLen() / sizeof(uint32); 43*f0bc043bSIngo Weinhold } 44*f0bc043bSIngo Weinhold BlockNumberAt(int32 index)45*f0bc043bSIngo Weinhold uint64 BlockNumberAt(int32 index) const 46*f0bc043bSIngo Weinhold { 47*f0bc043bSIngo Weinhold uint number = 0; 48*f0bc043bSIngo Weinhold if (index >= 0 && index < (int32)CountBlocks()) 49*f0bc043bSIngo Weinhold number = le2h(((uint32*)GetData())[index]); 50*f0bc043bSIngo Weinhold return number; 51*f0bc043bSIngo Weinhold } 52*f0bc043bSIngo Weinhold }; 53*f0bc043bSIngo Weinhold 54*f0bc043bSIngo Weinhold #endif // INDIRECT_ITEM_H 55