diff --git a/docs/user/storage/Query.dox b/docs/user/storage/Query.dox index 36d905a7f8..ecdf40eff6 100644 --- a/docs/user/storage/Query.dox +++ b/docs/user/storage/Query.dox @@ -330,6 +330,27 @@ */ +/*! + \fn status_t BQuery::SetFlags(uint32 flags) + \brief Sets the flags the query will be opened with. + + The possible flags to set are defined in \file fs_query.h. + + This methods fails if called after Fetch(). To reuse the BQuery object it + must first be reset via Clear(). + + \note The \c B_LIVE_QUERY flag will be ignored; BQuery always sets it automatically if necessary. + + \param flags The flags to set. + + \return A status code. + \retval B_OK Everything went fine. + \retval B_NOT_ALLOWED SetFlags() was called after Fetch(). + + \since Haiku R1 +*/ + + //! @} diff --git a/headers/os/storage/Query.h b/headers/os/storage/Query.h index 5201acb4a0..fde74152e2 100644 --- a/headers/os/storage/Query.h +++ b/headers/os/storage/Query.h @@ -63,7 +63,7 @@ public: status_t SetVolume(const BVolume* volume); status_t SetPredicate(const char* expression); status_t SetTarget(BMessenger messenger); - void SetFlags(uint32 flags); + status_t SetFlags(uint32 flags); bool IsLive() const; diff --git a/src/kits/storage/Query.cpp b/src/kits/storage/Query.cpp index 84b9b3bf99..bac63a6b0e 100644 --- a/src/kits/storage/Query.cpp +++ b/src/kits/storage/Query.cpp @@ -231,10 +231,14 @@ BQuery::SetTarget(BMessenger messenger) } -void +status_t BQuery::SetFlags(uint32 flags) { - fFlags = flags; + if (_HasFetched()) + return B_NOT_ALLOWED; + + fFlags = (flags & ~B_LIVE_QUERY); + return B_OK; }