本文整理汇总了C++中BVolume::KnowsQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ BVolume::KnowsQuery方法的具体用法?C++ BVolume::KnowsQuery怎么用?C++ BVolume::KnowsQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BVolume
的用法示例。
在下文中一共展示了BVolume::KnowsQuery方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BQuery
bool
GeneralView::_CanFindServer(entry_ref* ref)
{
// Try searching with be_roster
if (be_roster->FindApp(kNotificationServerSignature, ref) == B_OK)
return true;
// Try with a query and take the first result
BVolumeRoster vroster;
BVolume volume;
char volName[B_FILE_NAME_LENGTH];
vroster.Rewind();
while (vroster.GetNextVolume(&volume) == B_OK) {
if ((volume.InitCheck() != B_OK) || !volume.KnowsQuery())
continue;
volume.GetName(volName);
BQuery *query = new BQuery();
query->SetPredicate("(BEOS:APP_SIG==\""kNotificationServerSignature"\")");
query->SetVolume(&volume);
query->Fetch();
if (query->GetNextRef(ref) == B_OK)
return true;
}
return false;
}
示例2:
status_t
CDDBQuery::_OpenContentFile(const int32 &discID)
{
// Makes sure that the lookup has a valid file to work with for the CD
// content. Returns true if there is an existing file, false if a lookup is
// required.
BFile file;
BString predicate;
predicate << "CD:key == " << discID;
entry_ref ref;
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsReadOnly() || !volume.IsPersistent() || !volume.KnowsAttr()
|| !volume.KnowsQuery())
continue;
// make sure the volume we are looking at is indexed right
fs_create_index(volume.Device(), "CD:key", B_INT32_TYPE, 0);
BQuery query;
query.SetVolume(&volume);
query.SetPredicate(predicate.String());
if (query.Fetch() != B_OK)
continue;
if (query.GetNextRef(&ref) == B_OK)
break;
}
status_t status = fCDData.Load(ref);
if (status == B_NO_INIT) {
// We receive this error when the Load() function couldn't load the
// track times This just means that we get it from the SCSI data given
// to us in SetToCD
vector<CDAudioTime> times;
GetTrackTimes(&fSCSIData,times);
for (int32 i = 0; i < fCDData.CountTracks(); i++) {
CDAudioTime *item = fCDData.TrackTimeAt(i);
*item = times[i + 1] - times[i];
}
status = B_OK;
}
return status;
}
示例3:
void
TTracker::InstallIndices()
{
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsReadOnly() || !volume.IsPersistent()
|| !volume.KnowsAttr() || !volume.KnowsQuery())
continue;
InstallIndices(volume.Device());
}
}
示例4: filePath
status_t
TeamWindow::_RetrieveMatchingSourceEntries(const BString& path,
BStringList* _entries)
{
BPath filePath(path);
status_t error = filePath.InitCheck();
if (error != B_OK)
return error;
_entries->MakeEmpty();
BQuery query;
BString predicate;
query.PushAttr("name");
query.PushString(filePath.Leaf());
query.PushOp(B_EQ);
error = query.GetPredicate(&predicate);
if (error != B_OK)
return error;
BVolumeRoster roster;
BVolume volume;
while (roster.GetNextVolume(&volume) == B_OK) {
if (!volume.KnowsQuery())
continue;
if (query.SetVolume(&volume) != B_OK)
continue;
error = query.SetPredicate(predicate.String());
if (error != B_OK)
continue;
if (query.Fetch() != B_OK)
continue;
entry_ref ref;
while (query.GetNextRef(&ref) == B_OK) {
filePath.SetTo(&ref);
_entries->Add(filePath.Path());
}
query.Clear();
}
return B_OK;
}
示例5:
void
Feeder::StartWatching()
{
BVolume *volume = new BVolume ;
while (fVolumeRoster.GetNextVolume(volume) != B_BAD_VALUE) {
if ((volume->IsRemovable() && !fMonitorRemovableDevices)
|| !volume->KnowsQuery())
continue ;
AddQuery(volume) ;
volume = new BVolume ;
}
fVolumeRoster.StartWatching(this) ;
}
示例6:
void
MusicCollectionWindow::_StartNewQuery()
{
fQueryReader->Reset();
fQueryHandler->Reset();
BString orgString = fQueryField->Text();
((ListViewListener<FileListItem>*)fEntryViewInterface)->SetQueryString(
orgString);
BVolume volume;
//BVolumeRoster().GetBootVolume(&volume);
BVolumeRoster roster;
while (roster.GetNextVolume(&volume) == B_OK) {
if (!volume.KnowsQuery())
continue;
BQuery* query = _CreateQuery(orgString);
query->SetVolume(&volume);
fQueryReader->AddQuery(query);
}
fQueryReader->Run();
}
示例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: ProgressWindow
void
ApplicationTypesWindow::_RemoveUninstalled()
{
// Note: this runs in the looper's thread, which isn't that nice
int32 removed = 0;
volatile bool quit = false;
BWindow* progressWindow =
new ProgressWindow(
B_TRANSLATE("Removing uninstalled application types"),
fTypeListView->FullListCountItems(), &quit);
progressWindow->AddToSubset(this);
progressWindow->Show();
for (int32 i = fTypeListView->FullListCountItems(); i-- > 0 && !quit;) {
MimeTypeItem* item = dynamic_cast<MimeTypeItem*>
(fTypeListView->FullListItemAt(i));
progressWindow->PostMessage(B_UPDATE_STATUS_BAR);
if (item == NULL)
continue;
// search for application on all volumes
bool found = false;
BVolumeRoster volumeRoster;
BVolume volume;
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
if (!volume.KnowsQuery())
continue;
BQuery query;
query.PushAttr("BEOS:APP_SIG");
query.PushString(item->Type());
query.PushOp(B_EQ);
query.SetVolume(&volume);
query.Fetch();
entry_ref ref;
if (query.GetNextRef(&ref) == B_OK) {
found = true;
break;
}
}
if (!found) {
BMimeType mimeType(item->Type());
mimeType.Delete();
removed++;
// We're blocking the message loop that received the MIME changes,
// so we dequeue all waiting messages from time to time
if (removed % 10 == 0)
UpdateIfNeeded();
}
}
progressWindow->PostMessage(B_QUIT_REQUESTED);
static BMessageFormat format(B_TRANSLATE("{0, plural, "
"one{# Application type could be removed} "
"other{# Application types could be removed}}"));
BString message;
format.Format(message, removed);
error_alert(message, B_OK, B_INFO_ALERT);
}
示例9: ExtractQueryVolumes
status_t ExtractQueryVolumes(BNode *node, vollist *volumes) {
int32 length = 0;
char *attr = ReadAttribute(*node, kTrackerQueryVolume, &length);
BVolumeRoster roster;
if (attr == NULL) {
roster.Rewind();
BVolume vol;
while (roster.GetNextVolume(&vol) == B_NO_ERROR) {
if ((vol.IsPersistent() == true) && (vol.KnowsQuery() == true)) {
volumes->push_back(vol);
};
};
} else {
BMessage msg;
msg.Unflatten(attr);
// !*YOINK*!d from that project... with the funny little doggie as a logo...
// OpenTracker, that's it!
time_t created;
off_t capacity;
for (int32 index = 0; msg.FindInt32("creationDate", index, &created) == B_OK;
index++) {
if ((msg.FindInt32("creationDate", index, &created) != B_OK)
|| (msg.FindInt64("capacity", index, &capacity) != B_OK))
return B_ERROR;
BVolume volume;
BString deviceName = "";
BString volumeName = "";
BString fshName = "";
if (msg.FindString("deviceName", &deviceName) == B_OK
&& msg.FindString("volumeName", &volumeName) == B_OK
&& msg.FindString("fshName", &fshName) == B_OK) {
// New style volume identifiers: We have a couple of characteristics,
// and compute a score from them. The volume with the greatest score
// (if over a certain threshold) is the one we're looking for. We
// pick the first volume, in case there is more than one with the
// same score.
int foundScore = -1;
roster.Rewind();
char name[B_FILE_NAME_LENGTH];
while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsPersistent() && volume.KnowsQuery()) {
// get creation time and fs_info
BDirectory root;
volume.GetRootDirectory(&root);
time_t cmpCreated;
fs_info info;
if (root.GetCreationTime(&cmpCreated) == B_OK
&& fs_stat_dev(volume.Device(), &info) == 0) {
// compute the score
int score = 0;
// creation time
if (created == cmpCreated)
score += 5;
// capacity
if (capacity == volume.Capacity())
score += 4;
// device name
if (deviceName == info.device_name)
score += 3;
// volume name
if (volumeName == info.volume_name)
score += 2;
// fsh name
if (fshName == info.fsh_name)
score += 1;
// check score
if (score >= 9 && score > foundScore) {
volume.GetName(name);
volumes->push_back(volume);
}
}
}
}
} else {
// Old style volume identifiers: We have only creation time and
// capacity. Both must match.
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK)
if (volume.IsPersistent() && volume.KnowsQuery()) {
BDirectory root;
volume.GetRootDirectory(&root);
time_t cmpCreated;
root.GetCreationTime(&cmpCreated);
if (created == cmpCreated && capacity == volume.Capacity()) {
volumes->push_back(volume);
}
}
}
//.........这里部分代码省略.........
示例10: QueryListRep
//.........这里部分代码省略.........
buffer.UnlockBuffer();
// read the extra options
MoreOptionsStruct saveMoreOptions;
if (ReadAttr(model->Node(), kAttrQueryMoreOptions,
kAttrQueryMoreOptionsForeign, B_RAW_TYPE, 0, &saveMoreOptions,
sizeof(MoreOptionsStruct),
&MoreOptionsStruct::EndianSwap) != kReadAttrFailed) {
fQueryListRep->fShowResultsFromTrash = saveMoreOptions.searchTrash;
}
fStatus = query.SetPredicate(buffer.String());
fQueryListRep->fOldPoseList = oldPoseList;
fQueryListRep->fDynamicDateQuery = false;
fQueryListRep->fRefreshEveryHour = false;
fQueryListRep->fRefreshEveryMinute = false;
if (model->Node()->ReadAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0,
&fQueryListRep->fDynamicDateQuery,
sizeof(bool)) != sizeof(bool)) {
fQueryListRep->fDynamicDateQuery = false;
}
if (fQueryListRep->fDynamicDateQuery) {
// only refresh every minute on debug builds
fQueryListRep->fRefreshEveryMinute = buffer.IFindFirst("second") != -1
|| buffer.IFindFirst("minute") != -1;
fQueryListRep->fRefreshEveryHour = fQueryListRep->fRefreshEveryMinute
|| buffer.IFindFirst("hour") != -1;
#if !DEBUG
// don't refresh every minute unless we are running debug build
fQueryListRep->fRefreshEveryMinute = false;
#endif
}
if (fStatus != B_OK)
return;
bool searchAllVolumes = true;
status_t result = B_OK;
// get volumes to perform query on
if (model->Node()->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) {
char* buffer = NULL;
if ((buffer = (char*)malloc((size_t)info.size)) != NULL
&& model->Node()->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0,
buffer, (size_t)info.size) == info.size) {
BMessage message;
if (message.Unflatten(buffer) == B_OK) {
for (int32 index = 0; ;index++) {
ASSERT(index < 100);
BVolume volume;
// match a volume with the info embedded in
// the message
result = MatchArchivedVolume(&volume, &message, index);
if (result == B_OK) {
// start the query on this volume
result = FetchOneQuery(&query, target,
fQueryListRep->fQueryList, &volume);
if (result != B_OK)
continue;
searchAllVolumes = false;
} else if (result != B_DEV_BAD_DRIVE_NUM) {
// if B_DEV_BAD_DRIVE_NUM, the volume just isn't
// mounted this time around, keep looking for more
// if other error, bail
break;
}
}
}
}
free(buffer);
}
if (searchAllVolumes) {
// no specific volumes embedded in query, search everything
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK)
if (volume.IsPersistent() && volume.KnowsQuery()) {
result = FetchOneQuery(&query, target,
fQueryListRep->fQueryList, &volume);
if (result != B_OK)
continue;
}
}
fStatus = B_OK;
return;
}
示例11: entry
void
LiveQuery::ArgvReceived(int32 argc, char** argv)
{
fArgsReceived = true;
// Which volume do we make the query on?
// Default to the current volume.
char volumePath[B_FILE_NAME_LENGTH];
strcpy(volumePath, ".");
// Parse command-line arguments.
int opt;
while ((opt = getopt(argc, argv, "efav:")) != -1) {
switch (opt) {
case 'e':
sEscapeMetaChars = false;
break;
case 'f':
sFilesOnly = true;
break;
case 'a':
sAllVolumes = true;
break;
case 'v':
strncpy(volumePath, optarg, B_FILE_NAME_LENGTH);
break;
default:
_PrintUsage();
break;
}
}
BVolume volume;
if (!sAllVolumes) {
// Find the volume that the query should be performed on,
// and set the query to it.
BEntry entry(volumePath);
if (entry.InitCheck() != B_OK) {
fprintf(stderr, "%s: \"%s\" is not a valid file\n", kProgramName,
volumePath);
exit(1);
}
status_t status = entry.GetVolume(&volume);
if (status != B_OK) {
fprintf(stderr, "%s: could not get volume: %s\n", kProgramName,
strerror(status));
exit(1);
}
if (!volume.KnowsQuery()) {
fprintf(stderr, "%s: volume containing %s is not query-enabled\n",
kProgramName, volumePath);
} else
_AddQuery(volume, argv[optind]);
} else {
// Okay, we want to query all the disks -- so iterate over
// them, one by one, running the query.
BVolumeRoster volumeRoster;
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
// We don't print errors here -- this will catch /pipe and
// other filesystems we don't care about.
if (volume.KnowsQuery())
_AddQuery(volume, argv[optind]);
}
}
}