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