1 /* 2 * Copyright 2010, Haiku Inc. All rights reserved. 3 * This file may be used under the terms of the MIT License. 4 * 5 * Authors: 6 * Janito V. Ferreira Filho 7 */ 8 #ifndef HTREE_ENTRY_ITERATOR_H 9 #define HTREE_ENTRY_ITERATOR_H 10 11 12 #include <AutoDeleter.h> 13 14 #include "DirectoryIterator.h" 15 16 17 class Volume; 18 19 20 class HTreeEntryIterator { 21 public: 22 HTreeEntryIterator(off_t offset, 23 Inode* directory); 24 ~HTreeEntryIterator(); 25 26 status_t Init(); 27 28 status_t Lookup(uint32 hash, int indirections, 29 DirectoryIterator** iterator, 30 bool& detachRoot); 31 bool HasCollision() { return fHasCollision; } 32 33 status_t GetNext(uint32& offset); 34 35 uint32 BlocksNeededForNewEntry(); 36 status_t InsertEntry(Transaction& transaction, 37 uint32 hash, off_t block, 38 off_t newBlocksPos, bool hasCollision); 39 private: 40 HTreeEntryIterator(uint32 block, 41 uint32 blockSize, Inode* directory, 42 HTreeEntryIterator* parent, 43 bool hasCollision); 44 45 ext2_htree_tail* _HTreeEntryTail(uint8* block) const; 46 uint32 _Checksum(uint8* block) const; 47 void _SetHTreeEntryChecksum(uint8* block); 48 49 private: 50 Inode* fDirectory; 51 Volume* fVolume; 52 status_t fInitStatus; 53 54 bool fHasCollision; 55 uint16 fLimit, fCount; 56 uint16 fFirstEntry; 57 uint16 fCurrentEntry; 58 59 uint32 fBlockSize; 60 fsblock_t fBlockNum; 61 62 HTreeEntryIterator* fParent; 63 HTreeEntryIterator* fChild; 64 }; 65 66 #endif // HTREE_ENTRY_ITERATOR_H 67