本文整理汇总了C++中BDirectory::ReadAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ BDirectory::ReadAttr方法的具体用法?C++ BDirectory::ReadAttr怎么用?C++ BDirectory::ReadAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BDirectory
的用法示例。
在下文中一共展示了BDirectory::ReadAttr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: volume
bool
CDDBDaemon::_CanLookup(const dev_t device, uint32* cddbId,
scsi_toc_toc* toc) const
{
if (cddbId == NULL || toc == NULL)
return false;
// Is it an Audio disk?
fs_info info;
fs_stat_dev(device, &info);
if (strncmp(info.fsh_name, kCddaFsName, strlen(kCddaFsName)) != 0)
return false;
// Does it have the CD:do_lookup attribute and is it true?
BVolume volume(device);
BDirectory directory;
volume.GetRootDirectory(&directory);
bool doLookup;
if (directory.ReadAttr("CD:do_lookup", B_BOOL_TYPE, 0, (void *)&doLookup,
sizeof(bool)) < B_OK || !doLookup)
return false;
// Does it have the CD:cddbid attribute?
if (directory.ReadAttr("CD:cddbid", B_UINT32_TYPE, 0, (void *)cddbId,
sizeof(uint32)) < B_OK)
return false;
// Does it have the CD:toc attribute?
if (directory.ReadAttr("CD:toc", B_RAW_TYPE, 0, (void *)toc,
kMaxTocSize) < B_OK)
return false;
return true;
}
示例2: entry
void
TTracker::ReadyToRun()
{
gStatusWindow = new BStatusWindow();
InitMimeTypes();
InstallDefaultTemplates();
InstallIndices();
HideVarDir();
fTrashWatcher = new BTrashWatcher();
fTrashWatcher->Run();
fClipboardRefsWatcher = new BClipboardRefsWatcher();
fClipboardRefsWatcher->Run();
fAutoMounter = new AutoMounter();
fAutoMounter->Run();
fTaskLoop = new StandAloneTaskLoop(true);
bool openDisksWindow = false;
// open desktop window
BContainerWindow *deskWindow = NULL;
BVolume bootVol;
BVolumeRoster().GetBootVolume(&bootVol);
BDirectory deskDir;
if (FSGetDeskDir(&deskDir, bootVol.Device()) == B_OK) {
// create desktop
BEntry entry;
deskDir.GetEntry(&entry);
Model *model = new Model(&entry);
if (model->InitCheck() == B_OK) {
AutoLock<WindowList> lock(&fWindowList);
deskWindow = new BDeskWindow(&fWindowList);
AutoLock<BWindow> windowLock(deskWindow);
deskWindow->CreatePoseView(model);
deskWindow->Init();
} else
delete model;
// open previously open windows
attr_info attrInfo;
if (!BootedInSafeMode()
&& deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) == B_OK) {
char *buffer = (char *)malloc((size_t)attrInfo.size);
BMessage message;
if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size)
== attrInfo.size
&& message.Unflatten(buffer) == B_OK) {
node_ref nodeRef;
deskDir.GetNodeRef(&nodeRef);
int32 stateMessageCounter = 0;
const char *path;
for (int32 outer = 0;message.FindString("paths", outer, &path) == B_OK;outer++) {
int8 flags = 0;
for (int32 inner = 0;message.FindInt8(path, inner, &flags) == B_OK;inner++) {
BEntry entry(path, true);
if (entry.InitCheck() == B_OK) {
Model *model = new Model(&entry);
if (model->InitCheck() == B_OK && model->IsContainer()) {
BMessage state;
bool restoreStateFromMessage = false;
if ((flags & kOpenWindowHasState) != 0
&& message.FindMessage("window state", stateMessageCounter++, &state) == B_OK)
restoreStateFromMessage = true;
if (restoreStateFromMessage)
OpenContainerWindow(model, 0, kOpen,
kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U),
false, &state);
else
OpenContainerWindow(model, 0, kOpen,
kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U));
} else
delete model;
}
}
}
if (message.HasBool("open_disks_window"))
openDisksWindow = true;
}
free(buffer);
}
}
// create model for root of everything
if (deskWindow) {
BEntry entry("/");
Model model(&entry);
if (model.InitCheck() == B_OK) {
if (TrackerSettings().ShowDisksIcon()) {
// add the root icon to desktop window
BMessage message;
message.what = B_NODE_MONITOR;
//.........这里部分代码省略.........
示例3: fileNameNoExt
status_t
RunPopUpMenu(BPoint where, BString &header, BString &fileName,
CLanguageInterface *languageInterface)
{
status_t err;
BPath path;
BDirectory dir;
err = GetSettingsDir(dir, path);
err = B_ERROR;
BPopUpMenu *menu = BuildPopUp(dir);
if (menu == NULL)
return B_ERROR;
BMenuItem *item = menu->Go(where, false, true);
//if (item && item->Message())
// item->Message()->PrintToStream();
switch ((item && item->Message()) ? item->Message()->what : 0)
{
case 'head':
{
if (item->Message()->FindString("template", &header) < B_OK)
break;
BString tmp;
time_t now = time(NULL);
struct tm *tim = localtime(&now);
// date
char *p;
p = tmp.LockBuffer(100);
memset(p, 0, 100);
strftime(p, 100, "%Y-%m-%d", tim);
tmp.UnlockBuffer();
header.ReplaceAll("%DATE%", tmp.String());
tmp.Truncate(0);
p = tmp.LockBuffer(100);
memset(p, 0, 100);
strftime(p, 100, "%T", tim);
tmp.UnlockBuffer();
header.ReplaceAll("%TIME%", tmp.String());
tmp.Truncate(0);
// year
p = tmp.LockBuffer(10);
memset(p, 0, 10);
strftime(p, 10, "%Y", tim);
tmp.UnlockBuffer();
header.ReplaceAll("%YEAR%", tmp.String());
tmp.Truncate(0);
// fetch from query on META:email==** ?
p = tmp.LockBuffer(B_PATH_NAME_LENGTH);
memset(p, 0, B_PATH_NAME_LENGTH);
err = dir.ReadAttr("pe:author_people", B_STRING_TYPE, 0LL, p,
B_PATH_NAME_LENGTH);
tmp.UnlockBuffer();
//printf("ppl:%s\n", tmp.String());
BNode people;
if (err > 0)
people.SetTo(tmp.String());
tmp.Truncate(0);
BString attr;
static struct {
const char *tmplName;
const char *attrName;
} attrMap[] = {
{ "%AUTHOR%", "META:name" },
{ "%AUTHORMAIL%", "META:email" },
{ "%COMPANY%", "META:company" },
{ "%AUTHORURL%", "META:url" },
{ NULL, NULL }
};
int i;
for (i = 0; attrMap[i].tmplName; i++)
{
p = attr.LockBuffer(256);
memset(p, 0, 256);
err = people.ReadAttr(attrMap[i].attrName, B_ANY_TYPE,
0LL, p, 256);
//printf("ReadAttr: %d, %s\n", err, attr.String());
attr.UnlockBuffer();
tmp << attr;
header.ReplaceAll(attrMap[i].tmplName, tmp.String());
tmp.Truncate(0);
attr.Truncate(0);
}
BString fileNameNoExt(fileName);
if (fileNameNoExt.FindLast('.') > -1)
fileNameNoExt.Truncate(fileNameNoExt.FindLast('.'));
header.ReplaceAll("%FILENAMENOEXT%", fileNameNoExt.String());
header.ReplaceAll("%FILENAME%", fileName.String());
/*
tmp << "Haiku";
header.ReplaceAll("%PROJECT%", tmp.String());
tmp.Truncate(0);
//.........这里部分代码省略.........