本文整理汇总了C++中BQuery::GetNextEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ BQuery::GetNextEntry方法的具体用法?C++ BQuery::GetNextEntry怎么用?C++ BQuery::GetNextEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BQuery
的用法示例。
在下文中一共展示了BQuery::GetNextEntry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BString
void
LiveQuery::_PerformQuery(BQuery& query)
{
status_t status = query.Fetch();
if (status != B_OK) {
fprintf(stderr, "%s: bad query expression\n", kProgramName);
return;
}
int32 count = 0;
BEntry entry;
BPath path;
while (query.GetNextEntry(&entry) == B_OK) {
if (sFilesOnly && !entry.IsFile())
continue;
if (entry.GetPath(&path) != B_OK) {
fprintf(stderr, "%s: could not get path for entry\n", kProgramName);
continue;
}
printf("%s\n", sEscapeMetaChars ? BString().CharacterEscape(
path.Path(), " ()?*&\"'[]^\\~|;!<>*$\t", '\\').String()
: path.Path());
count++;
}
printf("FOUND %ld entries\n", count);
}
示例2: file
int32
add_query_menu_items(BMenu* menu, const char* attribute, uint32 what,
const char* format, bool popup)
{
BVolume volume;
BVolumeRoster().GetBootVolume(&volume);
BQuery query;
query.SetVolume(&volume);
query.PushAttr(attribute);
query.PushString("*");
query.PushOp(B_EQ);
query.Fetch();
int32 index = 0;
BEntry entry;
while (query.GetNextEntry(&entry) == B_OK) {
BFile file(&entry, B_READ_ONLY);
if (file.InitCheck() == B_OK) {
BMessage* message = new BMessage(what);
entry_ref ref;
entry.GetRef(&ref);
message->AddRef("ref", &ref);
BString value;
if (file.ReadAttrString(attribute, &value) < B_OK)
continue;
message->AddString("attribute", value.String());
BString name;
if (format != NULL)
name.SetToFormat(format, value.String());
else
name = value;
if (index < 9 && !popup)
menu->AddItem(new BMenuItem(name, message, '1' + index));
else
menu->AddItem(new BMenuItem(name, message));
index++;
}
}
return index;
}
示例3: BPopUpMenu
BPopUpMenu*
TPrefsWindow::_BuildSignatureMenu(char* sig)
{
char name[B_FILE_NAME_LENGTH];
BEntry entry;
BFile file;
BMenuItem* item;
BMessage* msg;
BQuery query;
BVolume vol;
BVolumeRoster volume;
BPopUpMenu* menu = new BPopUpMenu("");
msg = new BMessage(P_SIG);
msg->AddString("signature", B_TRANSLATE("None"));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("None"), msg));
if (!strcmp(sig, B_TRANSLATE("None")))
item->SetMarked(true);
msg = new BMessage(P_SIG);
msg->AddString("signature", B_TRANSLATE("Random"));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Random"), msg));
if (!strcmp(sig, B_TRANSLATE("Random")))
item->SetMarked(true);
menu->AddSeparatorItem();
volume.GetBootVolume(&vol);
query.SetVolume(&vol);
query.SetPredicate("_signature = *");
query.Fetch();
while (query.GetNextEntry(&entry) == B_NO_ERROR) {
file.SetTo(&entry, O_RDONLY);
if (file.InitCheck() == B_NO_ERROR) {
msg = new BMessage(P_SIG);
file.ReadAttr("_signature", B_STRING_TYPE, 0, name, sizeof(name));
msg->AddString("signature", name);
menu->AddItem(item = new BMenuItem(name, msg));
if (!strcmp(sig, name))
item->SetMarked(true);
}
}
return menu;
}
示例4:
bool
TStatusWindow::_Exists(const char* status)
{
BVolume volume;
BVolumeRoster().GetBootVolume(&volume);
BQuery query;
query.SetVolume(&volume);
query.PushAttr(INDEX_STATUS);
query.PushString(status);
query.PushOp(B_EQ);
query.Fetch();
BEntry entry;
if (query.GetNextEntry(&entry) == B_NO_ERROR)
return true;
return false;
}
示例5:
uint32
FetchQuery(query_op op, const char* selection, vector<BString>& results,
bool caseSensitive = false)
{
BQuery query;
query.PushAttr("BEOS:TYPE");
query.PushString("application/x-vnd.Be-doc_bookmark");
query.PushOp(B_EQ);
query.PushAttr("name");
query.PushString(selection, caseSensitive);
query.PushOp(op);
query.PushOp(B_AND);
BVolume vol;
BVolumeRoster roster;
roster.GetBootVolume(&vol);
query.SetVolume(&vol);
if (B_NO_INIT == query.Fetch())
return 0;
BEntry entry;
BPath path;
int32 counter = 0;
while (query.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
if (entry.InitCheck() == B_OK) {
entry.GetPath(&path);
if (path.InitCheck() == B_OK) {
results.push_back(path.Path());
counter++;
}
}
}
return counter;
}
示例6: volume
int
main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "usage: %s <message-code>\n", __progname);
return -1;
}
int32 number = atol(argv[1]);
BQuery query;
query.SetPredicate("name=ServerProtocol.h");
// search on current volume only
dev_t device = dev_for_path(".");
BVolume volume(device);
query.SetVolume(&volume);
query.Fetch();
status_t status;
BEntry entry;
while ((status = query.GetNextEntry(&entry)) == B_OK) {
BPath path(&entry);
puts(path.Path());
if (strstr(path.Path(), "headers/private/app/ServerProtocol.h") != NULL) {
print_code(path, number);
break;
}
}
if (status != B_OK) {
fprintf(stderr, "%s: could not find ServerProtocol.h", __progname);
return -1;
}
return 0;
}
示例7: duplicates_exist
bool duplicates_exist (const char * signature)
{
BVolumeRoster roster;
BVolume volume;
BQuery query;
BString query_string = "BEOS:APP_SIG=";
BEntry entry;
mode_t permissions;
uid_t owner;
gid_t group;
int32 query_hits = 0;
query_string += signature;
while (roster.GetNextVolume(& volume) == B_OK)
{
if (volume.KnowsQuery())
{
PRINT(("volume.KnowsQuery()\n"));
char volname [B_FILE_NAME_LENGTH];
volume.GetName(volname);
PRINT(("volume: %s\n", volname));
query.Clear();
if (query.SetVolume(& volume) == B_OK)
{
PRINT(("query.SetVolume(& volume) == B_OK\n"));
if (query.SetPredicate(query_string.String()) == B_OK)
{
PRINT(("query.SetPredicate(%s) == B_OK\n", query_string.String()));
if (query.Fetch() == B_OK)
{
PRINT(("query.Fetch() == B_OK\n"));
while (query.GetNextEntry(& entry) == B_OK)
{
PRINT(("query.GetNextEntry(& entry) == B_OK\n"));
entry.GetPermissions(& permissions);
entry.GetOwner(& owner);
entry.GetGroup(& group);
BPath path (& entry);
// if (access(path.Path(), X_OK))
if (((owner == getuid()) && (permissions & S_IXUSR))
|| ((group == getgid()) && (permissions & S_IXGRP))
|| (permissions & S_IXOTH))
{
PRINT(("path is executable: %s\n", path.Path()));
query_hits++;
}
else
{
PRINT(("path is NOT executable: %s\n", path.Path()));
}
}
}
}
}
}
fflush(stdout);
}
if (query_hits > 1)
return true;
else
return false;
}
示例8: file
void
PersonView::BuildGroupMenu()
{
if (fGroups == NULL)
return;
BMenuItem* item;
while ((item = fGroups->ItemAt(0)) != NULL) {
fGroups->RemoveItem(item);
delete item;
}
int32 count = 0;
BVolumeRoster volumeRoster;
BVolume volume;
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
BQuery query;
query.SetVolume(&volume);
char buffer[256];
snprintf(buffer, sizeof(buffer), "%s=*", fCategoryAttribute.String());
query.SetPredicate(buffer);
query.Fetch();
BEntry entry;
while (query.GetNextEntry(&entry) == B_OK) {
BFile file(&entry, B_READ_ONLY);
attr_info info;
if (file.InitCheck() == B_OK
&& file.GetAttrInfo(fCategoryAttribute, &info) == B_OK
&& info.size > 1) {
if (info.size > (off_t)sizeof(buffer))
info.size = sizeof(buffer);
if (file.ReadAttr(fCategoryAttribute.String(), B_STRING_TYPE,
0, buffer, info.size) < 0) {
continue;
}
const char *text = buffer;
while (true) {
char* offset = strstr(text, ",");
if (offset != NULL)
offset[0] = '\0';
if (!fGroups->FindItem(text)) {
int32 index = 0;
while ((item = fGroups->ItemAt(index)) != NULL) {
if (strcmp(text, item->Label()) < 0)
break;
index++;
}
BMessage* message = new BMessage(M_GROUP_MENU);
message->AddString("group", text);
fGroups->AddItem(new BMenuItem(text, message), index);
count++;
}
if (offset) {
text = offset + 1;
while (*text == ' ')
text++;
}
else
break;
}
}
}
}
if (count == 0) {
fGroups->AddItem(item = new BMenuItem(
B_TRANSLATE_CONTEXT("none", "Groups list"),
new BMessage(M_GROUP_MENU)));
item->SetEnabled(false);
}
fGroups->SetTargetForItems(this);
}