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