16f4c36e2SJérôme Duval /* 299768086Shyche * Copyright 2017, Chế Vũ Gia Hy, cvghy116@gmail.com. 36f4c36e2SJérôme Duval * Copyright 2011, Jérôme Duval, korli@users.berlios.de. 46f4c36e2SJérôme Duval * This file may be used under the terms of the MIT License. 56f4c36e2SJérôme Duval */ 66f4c36e2SJérôme Duval #ifndef DIRECTORYITERATOR_H 76f4c36e2SJérôme Duval #define DIRECTORYITERATOR_H 86f4c36e2SJérôme Duval 96f4c36e2SJérôme Duval 10299aba38Shyche #include "BTree.h" 116f4c36e2SJérôme Duval #include "Inode.h" 126f4c36e2SJérôme Duval 136f4c36e2SJérôme Duval 14*ef52a3d4Sbrjhaiku //! Class used to iterate through entries in a directory 156f4c36e2SJérôme Duval class DirectoryIterator { 166f4c36e2SJérôme Duval public: 176f4c36e2SJérôme Duval DirectoryIterator(Inode* inode); 186f4c36e2SJérôme Duval ~DirectoryIterator(); 196f4c36e2SJérôme Duval 206f4c36e2SJérôme Duval status_t InitCheck(); 216f4c36e2SJérôme Duval 22*ef52a3d4Sbrjhaiku /*! Get details of next entry 23*ef52a3d4Sbrjhaiku * \param name Location to copy name of next entry 24*ef52a3d4Sbrjhaiku * \param _nameLength Location to copy length of next entry's name 25*ef52a3d4Sbrjhaiku * \param _id Location to copy inode number of next entry 26*ef52a3d4Sbrjhaiku */ 276f4c36e2SJérôme Duval status_t GetNext(char* name, size_t* _nameLength, ino_t* _id); 28*ef52a3d4Sbrjhaiku /*! Search for item in current directory 29*ef52a3d4Sbrjhaiku * \param name Name of entry to lookup 30*ef52a3d4Sbrjhaiku * \param nameLength Length of name being searched 31*ef52a3d4Sbrjhaiku * \param _id inode value of entry if found, ??? otherwise 32*ef52a3d4Sbrjhaiku */ 336f4c36e2SJérôme Duval status_t Lookup(const char* name, size_t nameLength, ino_t* _id); 34*ef52a3d4Sbrjhaiku //! Reset iterator to beginning 356f4c36e2SJérôme Duval status_t Rewind(); 366f4c36e2SJérôme Duval private: 376f4c36e2SJérôme Duval uint64 fOffset; 386f4c36e2SJérôme Duval Inode* fInode; 396f4c36e2SJérôme Duval TreeIterator* fIterator; 406f4c36e2SJérôme Duval }; 416f4c36e2SJérôme Duval 426f4c36e2SJérôme Duval 436f4c36e2SJérôme Duval #endif // DIRECTORYITERATOR_H 44