xref: /haiku/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.h (revision 15fb7d88e971c4d6c787c6a3a5c159afb1ebf77b)
1 /*
2  * Copyright 2017, Chế Vũ Gia Hy, cvghy116@gmail.com.
3  * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
4  * This file may be used under the terms of the MIT License.
5  */
6 #ifndef DIRECTORYITERATOR_H
7 #define DIRECTORYITERATOR_H
8 
9 
10 #include "BTree.h"
11 #include "Inode.h"
12 
13 
14 //! Class used to iterate through entries in a directory
15 class DirectoryIterator {
16 public:
17 								DirectoryIterator(Inode* inode);
18 								~DirectoryIterator();
19 
20 			status_t			InitCheck();
21 
22 			/*! Get details of next entry
23 			 * \param name Location to copy name of next entry
24 			 * \param _nameLength Location to copy length of next entry's name
25 			 * \param _id Location to copy inode number of next entry
26 			 */
27 			status_t			GetNext(char* name, size_t* _nameLength, ino_t* _id);
28 			/*! Search for item in current directory
29 			 * \param name Name of entry to lookup
30 			 * \param nameLength Length of name being searched
31 			 * \param _id inode value of entry if found, ??? otherwise
32 			 */
33 			status_t			Lookup(const char* name, size_t nameLength, ino_t* _id);
34 			//! Reset iterator to beginning
35 			status_t			Rewind();
36 private:
37 			uint64				fOffset;
38 			Inode* 				fInode;
39 			TreeIterator*		fIterator;
40 };
41 
42 
43 #endif	// DIRECTORYITERATOR_H
44