xref: /haiku/src/add-ons/kernel/file_systems/ext2/HTreeEntryIterator.h (revision 837b16251d4b2b6249ebcaa19bb319cbe82c6126)
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 private:
46 			Inode*				fDirectory;
47 			Volume*				fVolume;
48 			status_t			fInitStatus;
49 
50 			bool				fHasCollision;
51 			uint16				fLimit, fCount;
52 			uint16				fFirstEntry;
53 			uint16				fCurrentEntry;
54 
55 			uint32				fBlockSize;
56 			fsblock_t			fBlockNum;
57 
58 			HTreeEntryIterator*	fParent;
59 			HTreeEntryIterator*	fChild;
60 };
61 
62 #endif	// HTREE_ENTRY_ITERATOR_H
63