[haiku-3rdparty-dev] Fetching data from queries

  • From: "Yashasvi A.C." <yashasviac@xxxxxxxxx>
  • To: haiku-3rdparty-dev <haiku-3rdparty-dev@xxxxxxxxxxxxx>
  • Date: Thu, 5 Nov 2009 15:28:29 +1300

Hi,

I have been storing messages as flattened file streams in the "/boot/home"
directory. In the screenshot displayed, the EventLog tab contains a button
called "Refresh". What I would like to do is find out the message files that
have been created in the last 10 seconds or so. This is the code snippet
that I have used:

*void HelpWindow::MessageReceived(BMessage* message)
{
BEntry entry("/boot/home");
BVolume tempVolume;
entry.GetVolume(&tempVolume);

BQuery query;
BEntry resultEntry;

switch(message->what){

case 'Refr':
query.SetVolume(&tempVolume);
query.SetPredicate("last_modified > 0 && last_modified < 10000000");
query.Fetch();

while (query.GetNextEntry(&resultEntry) == B_OK){
printf("Hi Yash! \n");
}

break;
}

}

*In the code snippet, I have used the predicate to check whether there is
any file within the last 10 seconds ( I hope my predicate is correct there).
Nothing is printed with this code.
If I place a predicate with just last_modified > 0, then, a series of "Hi
Yash" is printed (as seen in the screenshot). My understand is that if there
are only 4 message files in the folder, shouldn't "Hi Yash" be printed only
4 times? Or does query.GetNextEntry(...) do something else? I would like to
note that there are 2 other folders within the /boot/home folder.

So, what exactly is wrong with the current predicate that I have? Is there
anything I can do to correct it to get files within the last 10 seconds?

Thanks for your help.

Regards,
Yash

Attachment: Refresh1.png
Description: PNG image

Other related posts: