1962a6c67SStephan Aßmus /* 2962a6c67SStephan Aßmus * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de> 3962a6c67SStephan Aßmus * Copyright (c) 1998-2007 Matthijs Hollemans 4*90ce3113SAugustin Cavalier * All rights reserved. Distributed under the terms of the MIT License. 5962a6c67SStephan Aßmus */ 6962a6c67SStephan Aßmus #ifndef INITIAL_ITERATOR_H 7962a6c67SStephan Aßmus #define INITIAL_ITERATOR_H 8962a6c67SStephan Aßmus 9962a6c67SStephan Aßmus #include <List.h> 10962a6c67SStephan Aßmus #include <Message.h> 11962a6c67SStephan Aßmus 12962a6c67SStephan Aßmus #include "FileIterator.h" 13962a6c67SStephan Aßmus 14962a6c67SStephan Aßmus class BEntry; 15962a6c67SStephan Aßmus class BDirectory; 16962a6c67SStephan Aßmus class Model; 17962a6c67SStephan Aßmus 18962a6c67SStephan Aßmus // TODO: split into Folder and MessageFileIterator (_GetTopEntry) 19962a6c67SStephan Aßmus // This code either has an original folder to start iterating from, 20962a6c67SStephan Aßmus // or it uses the refs in the message that contains the selected poses 21962a6c67SStephan Aßmus // from the Tracker window that invoked us. But I think if folders are 22962a6c67SStephan Aßmus // among those poses, it will then use the same code for examining sub 23962a6c67SStephan Aßmus // folders. 24962a6c67SStephan Aßmus 25962a6c67SStephan Aßmus // Provides an interface to retrieve the next file that should be grepped 26962a6c67SStephan Aßmus // for the search string. 27962a6c67SStephan Aßmus class InitialIterator : public FileIterator { 28962a6c67SStephan Aßmus public: 29962a6c67SStephan Aßmus InitialIterator(const Model* model); 30962a6c67SStephan Aßmus virtual ~InitialIterator(); 31962a6c67SStephan Aßmus 32962a6c67SStephan Aßmus virtual bool IsValid() const; 33962a6c67SStephan Aßmus virtual bool GetNextName(char* buffer); 34962a6c67SStephan Aßmus virtual bool NotifyNegatives() const; 35962a6c67SStephan Aßmus 36962a6c67SStephan Aßmus // Looks for the next entry in the top-level dir. 37962a6c67SStephan Aßmus bool GetTopEntry(BEntry& entry); 38962a6c67SStephan Aßmus 39962a6c67SStephan Aßmus // Should this subfolder be followed? 40962a6c67SStephan Aßmus bool FollowSubdir(BEntry& entry) const; 41962a6c67SStephan Aßmus 42962a6c67SStephan Aßmus private: 43962a6c67SStephan Aßmus // Looks for the next entry. 44962a6c67SStephan Aßmus bool _GetNextEntry(BEntry& entry); 45962a6c67SStephan Aßmus 46962a6c67SStephan Aßmus // Looks for the next entry in a subdir. 47962a6c67SStephan Aßmus bool _GetSubEntry(BEntry& entry); 48962a6c67SStephan Aßmus 49962a6c67SStephan Aßmus // Determines whether we can add a subdir. 50962a6c67SStephan Aßmus void _ExamineSubdir(BEntry& entry); 51962a6c67SStephan Aßmus 52962a6c67SStephan Aßmus private: 53962a6c67SStephan Aßmus // Contains pointers to BDirectory objects. 54962a6c67SStephan Aßmus BList fDirectories; 55962a6c67SStephan Aßmus 56962a6c67SStephan Aßmus // The directory we are currently looking at. 57962a6c67SStephan Aßmus BDirectory* fCurrentDir; 58962a6c67SStephan Aßmus 59962a6c67SStephan Aßmus // The ref number we are currently looking at. 60962a6c67SStephan Aßmus int32 fCurrentRef; 61962a6c67SStephan Aßmus 62962a6c67SStephan Aßmus // The current settings 63962a6c67SStephan Aßmus BMessage fSelectedFiles; 64962a6c67SStephan Aßmus 65962a6c67SStephan Aßmus bool fRecurseDirs : 1; 66962a6c67SStephan Aßmus bool fRecurseLinks : 1; 67962a6c67SStephan Aßmus bool fSkipDotDirs : 1; 68962a6c67SStephan Aßmus bool fTextOnly : 1; 69962a6c67SStephan Aßmus }; 70962a6c67SStephan Aßmus 71962a6c67SStephan Aßmus #endif // INITIAL_ITERATOR_H 72