1 /* 2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de. 3 * This file may be used under the terms of the MIT License. 4 */ 5 #ifndef _QUERY_FILE_H 6 #define _QUERY_FILE_H 7 8 9 #include <EntryList.h> 10 #include <Query.h> 11 #include <List.h> 12 #include <String.h> 13 14 15 class BQueryFile : public BEntryList { 16 public: 17 BQueryFile(const entry_ref& ref); 18 BQueryFile(const BEntry& entry); 19 BQueryFile(const char* path); 20 BQueryFile(BQuery& query); 21 virtual ~BQueryFile(); 22 23 status_t InitCheck() const; 24 25 status_t SetTo(const entry_ref& ref); 26 status_t SetTo(const BEntry& entry); 27 status_t SetTo(const char* path); 28 status_t SetTo(BQuery& query); 29 void Unset(); 30 31 status_t SetPredicate(const char* predicate); 32 status_t AddVolume(const BVolume& volume); 33 status_t AddVolume(dev_t device); 34 35 const char* Predicate() const; 36 int32 CountVolumes() const; 37 dev_t VolumeAt(int32 index) const; 38 39 status_t WriteTo(const entry_ref& ref); 40 status_t WriteTo(const char* path); 41 42 // BEntryList implementation 43 44 virtual status_t GetNextEntry(BEntry* entry, 45 bool traverse = false); 46 virtual status_t GetNextRef(entry_ref* ref); 47 virtual int32 GetNextDirents(struct dirent* buffer, 48 size_t length, int32 count = INT_MAX); 49 virtual status_t Rewind(); 50 virtual int32 CountEntries(); 51 52 static const char* MimeType(); 53 54 private: 55 status_t _SetQuery(int32 index); 56 57 private: 58 status_t fStatus; 59 BString fPredicate; 60 BQuery fQuery; 61 BList fVolumes; 62 int32 fCurrentVolumeIndex; 63 }; 64 65 66 #endif // _QUERY_FILE_H 67