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
18class Inode;
19
20class EntryVisitor {
21public:
22								EntryVisitor() {};
23		virtual					~EntryVisitor() {};
24		virtual bool			VisitBitmap(struct exfat_entry*)
25									{ return false; }
26		virtual bool			VisitUppercase(struct exfat_entry*)
27									{ return false; }
28		virtual bool			VisitLabel(struct exfat_entry*)
29									{ return false; }
30		virtual bool			VisitFilename(struct exfat_entry*)
31									{ return false; }
32		virtual bool			VisitFile(struct exfat_entry*)
33									{ return false; }
34		virtual bool			VisitFileInfo(struct exfat_entry*)
35									{ return false; }
36};
37
38
39class DirectoryIterator {
40public:
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);
54private:
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