1 /* 2 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de> 3 * Copyright (c) 1998-2007 Matthijs Hollemans 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 #ifndef INITIAL_ITERATOR_H 24 #define INITIAL_ITERATOR_H 25 26 #include <List.h> 27 #include <Message.h> 28 29 #include "FileIterator.h" 30 31 class BEntry; 32 class BDirectory; 33 class Model; 34 35 // TODO: split into Folder and MessageFileIterator (_GetTopEntry) 36 // This code either has an original folder to start iterating from, 37 // or it uses the refs in the message that contains the selected poses 38 // from the Tracker window that invoked us. But I think if folders are 39 // among those poses, it will then use the same code for examining sub 40 // folders. 41 42 // Provides an interface to retrieve the next file that should be grepped 43 // for the search string. 44 class InitialIterator : public FileIterator { 45 public: 46 InitialIterator(const Model* model); 47 virtual ~InitialIterator(); 48 49 virtual bool IsValid() const; 50 virtual bool GetNextName(char* buffer); 51 virtual bool NotifyNegatives() const; 52 53 // Looks for the next entry in the top-level dir. 54 bool GetTopEntry(BEntry& entry); 55 56 // Should this subfolder be followed? 57 bool FollowSubdir(BEntry& entry) const; 58 59 private: 60 // Looks for the next entry. 61 bool _GetNextEntry(BEntry& entry); 62 63 // Looks for the next entry in a subdir. 64 bool _GetSubEntry(BEntry& entry); 65 66 // Determines whether we can add a subdir. 67 void _ExamineSubdir(BEntry& entry); 68 69 private: 70 // Contains pointers to BDirectory objects. 71 BList fDirectories; 72 73 // The directory we are currently looking at. 74 BDirectory* fCurrentDir; 75 76 // The ref number we are currently looking at. 77 int32 fCurrentRef; 78 79 // The current settings 80 BMessage fSelectedFiles; 81 82 bool fRecurseDirs : 1; 83 bool fRecurseLinks : 1; 84 bool fSkipDotDirs : 1; 85 bool fTextOnly : 1; 86 }; 87 88 #endif // INITIAL_ITERATOR_H 89