1 /* 2 * Copyright 2002-2012, Axel Dörfler, axeld@pinc-software.de. 3 * Copyright 2012, Andreas Henriksson, sausageboy@gmail.com 4 * This file may be used under the terms of the MIT License. 5 */ 6 #ifndef FILE_SYSTEM_VISITOR_H 7 #define FILE_SYSTEM_VISITOR_H 8 9 10 #include "system_dependencies.h" 11 12 #include "bfs.h" 13 14 15 class Inode; 16 class TreeIterator; 17 class Volume; 18 19 20 enum visitor_flags { 21 VISIT_REGULAR = 0x0001, 22 VISIT_INDICES = 0x0002, 23 VISIT_REMOVED = 0x0004, 24 VISIT_ATTRIBUTE_DIRECTORIES = 0x0008 25 }; 26 27 28 class FileSystemVisitor { 29 public: 30 FileSystemVisitor(Volume* volume); 31 virtual ~FileSystemVisitor(); 32 GetVolume()33 Volume* GetVolume() const { return fVolume; } 34 35 // traversing the file system 36 status_t Next(); 37 void Start(uint32 flags); 38 void Stop(); 39 40 41 virtual status_t VisitDirectoryEntry(Inode* inode, 42 Inode* parent, const char* treeName); 43 virtual status_t VisitInode(Inode* inode, const char* treeName); 44 45 virtual status_t OpenInodeFailed(status_t reason, ino_t id, 46 Inode* parent, char* treeName, 47 TreeIterator* iterator); 48 virtual status_t OpenBPlusTreeFailed(Inode* inode); 49 virtual status_t TreeIterationFailed(status_t reason, 50 Inode* parent); 51 52 private: 53 Volume* fVolume; 54 55 // state needed when traversing 56 block_run fCurrent; 57 Inode* fParent; 58 Stack<block_run> fStack; 59 TreeIterator* fIterator; 60 61 uint32 fFlags; 62 }; 63 64 65 #endif // FILE_SYSTEM_VISITOR_H 66