xref: /haiku/src/add-ons/kernel/file_systems/exfat/DirectoryIterator.h (revision ebd3bcdb9be2d6a57fc5b3270dcb49a9e1894d11)
1 /*
2  * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
3  * Copyright 2014 Haiku, Inc. All rights reserved.
4  *
5  * Distributed under the terms of the MIT License.
6  *
7  * Authors:
8  *		Jérôme Duval, korli@users.berlios.de
9  *		John Scipione, jscipione@gmail.com
10  */
11 #ifndef DIRECTORYITERATOR_H
12 #define DIRECTORYITERATOR_H
13 
14 
15 #include "CachedBlock.h"
16 #include "exfat.h"
17 
18 class Inode;
19 
20 class EntryVisitor {
21 public:
EntryVisitor()22 								EntryVisitor() {};
~EntryVisitor()23 		virtual					~EntryVisitor() {};
VisitBitmap(struct exfat_entry *)24 		virtual bool			VisitBitmap(struct exfat_entry*)
25 									{ return false; }
VisitUppercase(struct exfat_entry *)26 		virtual bool			VisitUppercase(struct exfat_entry*)
27 									{ return false; }
VisitLabel(struct exfat_entry *)28 		virtual bool			VisitLabel(struct exfat_entry*)
29 									{ return false; }
VisitFilename(struct exfat_entry *)30 		virtual bool			VisitFilename(struct exfat_entry*)
31 									{ return false; }
VisitFile(struct exfat_entry *)32 		virtual bool			VisitFile(struct exfat_entry*)
33 									{ return false; }
VisitFileInfo(struct exfat_entry *)34 		virtual bool			VisitFileInfo(struct exfat_entry*)
35 									{ return false; }
36 };
37 
38 
39 class DirectoryIterator {
40 public:
41 								DirectoryIterator(Inode* inode);
42 								~DirectoryIterator();
43 
44 			status_t			InitCheck();
45 
46 			status_t			GetNext(char* name, size_t* _nameLength,
47 									ino_t* _id, EntryVisitor* visitor = NULL);
48 			status_t			Lookup(const char* name, size_t nameLength,
49 									ino_t* _id);
50 			status_t			LookupEntry(EntryVisitor* visitor);
51 			status_t			Rewind();
52 
53 			void				Iterate(EntryVisitor &visitor);
54 private:
55 			status_t			_GetNext(uint16* unicodeName,
56 									size_t* _codeUnitCount, ino_t* _id,
57 									EntryVisitor* visitor = NULL);
58 			status_t			_NextEntry();
59 
60 			int64				fOffset;
61 			cluster_t			fCluster;
62 			Inode* 				fInode;
63 			CachedBlock			fBlock;
64 			struct exfat_entry*	fCurrent;
65 };
66 
67 
68 #endif	// DIRECTORYITERATOR_H
69