1 /* 2 * Copyright 2011, Jérôme Duval, korli@users.berlios.de. 3 * This file may be used under the terms of the MIT License. 4 */ 5 #ifndef DIRECTORYITERATOR_H 6 #define DIRECTORYITERATOR_H 7 8 9 #include "CachedBlock.h" 10 #include "exfat.h" 11 12 class Inode; 13 14 class EntryVisitor { 15 public: 16 EntryVisitor() {}; 17 virtual ~EntryVisitor() {}; 18 virtual bool VisitBitmap(struct exfat_entry*) 19 { return false; } 20 virtual bool VisitUppercase(struct exfat_entry*) 21 { return false; } 22 virtual bool VisitLabel(struct exfat_entry*) 23 { return false; } 24 virtual bool VisitFilename(struct exfat_entry*) 25 { return false; } 26 virtual bool VisitFile(struct exfat_entry*) 27 { return false; } 28 virtual bool VisitFileInfo(struct exfat_entry*) 29 { return false; } 30 }; 31 32 33 class DirectoryIterator { 34 public: 35 DirectoryIterator(Inode* inode); 36 ~DirectoryIterator(); 37 38 status_t InitCheck(); 39 40 status_t GetNext(char* name, size_t* _nameLength, 41 ino_t* _id, EntryVisitor* visitor = NULL); 42 status_t Lookup(const char* name, size_t nameLength, 43 ino_t* _id); 44 status_t LookupEntry(EntryVisitor* visitor); 45 status_t Rewind(); 46 47 void Iterate(EntryVisitor &visitor); 48 private: 49 status_t _GetNext(uchar* unicodename, 50 size_t* _nameLength, ino_t* _id, 51 EntryVisitor* visitor = NULL); 52 status_t _NextEntry(); 53 54 int64 fOffset; 55 cluster_t fCluster; 56 Inode* fInode; 57 CachedBlock fBlock; 58 struct exfat_entry* fCurrent; 59 }; 60 61 62 #endif // DIRECTORYITERATOR_H 63