本文整理汇总了C++中BEntry::GetRef方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::GetRef方法的具体用法?C++ BEntry::GetRef怎么用?C++ BEntry::GetRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEntry
的用法示例。
在下文中一共展示了BEntry::GetRef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msg
status_t
BackgroundThemesAddon::RunPreferencesPanel()
{
/* if (be_roster->Launch("application/x-vnd.obos-Backgrounds") < B_OK)
if (be_roster->Launch("application/x-vnd.Be-Backgrounds") < B_OK)
return B_ERROR;*/
status_t err;
entry_ref ref;
BEntry ent;
err = ent.SetTo("/boot/beos/preferences/Backgrounds");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
}
}
if (!err)
return B_OK;
err = ent.SetTo("/system/add-ons/Preferences/Backgrounds");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
if (err) {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app_messenger.SendMessage(&msg);
}
}
}
return err;
}
示例2:
status_t
ScreensaverThemesAddon::RunPreferencesPanel()
{
// Haiku
if (be_roster->Launch("application/x-vnd.Haiku-ScreenSaver") == B_OK)
return B_OK;
status_t err;
entry_ref ref;
BEntry ent;
// BeOS
err = ent.SetTo("/boot/beos/preferences/ScreenSaver");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
}
}
if (!err)
return B_OK;
// ZETA
err = ent.SetTo("/system/add-ons/Preferences/ScreenSaver");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
}
}
return err;
}
示例3: if
void
TBarWindow::MenusBeginning()
{
BPath path;
entry_ref ref;
BEntry entry;
if (GetDeskbarSettingsDirectory(path) == B_OK
&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
&& entry.SetTo(path.Path(), true) == B_OK
&& entry.Exists()
&& entry.GetRef(&ref) == B_OK) {
sDeskbarMenu->SetNavDir(&ref);
} else if (GetDeskbarDataDirectory(path) == B_OK
&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
&& entry.SetTo(path.Path(), true) == B_OK
&& entry.Exists()
&& entry.GetRef(&ref) == B_OK) {
sDeskbarMenu->SetNavDir(&ref);
} else {
// this really should never happen
TRESPASS();
return;
}
sDeskbarMenu->ResetTargets();
fShowingMenu = true;
BWindow::MenusBeginning();
}
示例4: msg
status_t
SoundsThemesAddon::RunPreferencesPanel()
{
status_t err;
entry_ref ref;
BEntry ent;
err = ent.SetTo("/boot/beos/preferences/Sounds");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
}
}
if (!err)
return B_OK;
err = ent.SetTo("/system/add-ons/Preferences/Sounds");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
if (err) {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app_messenger.SendMessage(&msg);
}
}
}
return err;
}
示例5: FlattenedSize
/*! \brief Converts the object's pathname to an entry_ref and writes it into
buffer.
Implements BFlattenable.
\param buffer the buffer the data shall be stored in
\param size the size of \a buffer
\return
- \c B_OK: Everything went fine.
- \c B_BAD_VALUE: \c NULL buffer or the buffer is of insufficient size.
- other error codes.
\todo Reimplement for performance reasons: Don't call FlattenedSize().
*/
status_t
BPath::Flatten(void* buffer, ssize_t size) const
{
if (buffer == NULL)
return B_BAD_VALUE;
ssize_t flattenedSize = FlattenedSize();
if (flattenedSize < 0)
return flattenedSize;
if (size < flattenedSize)
return B_BAD_VALUE;
status_t status = InitCheck();
if (status != B_OK)
return status;
// convert the path to an entry_ref
BEntry entry;
entry_ref ref;
status = entry.SetTo(Path());
if (status == B_OK)
status = entry.GetRef(&ref);
if (status != B_OK)
return status;
// store the entry_ref in the buffer
flattened_entry_ref& fref = *(flattened_entry_ref*)buffer;
fref.device = ref.device;
fref.directory = ref.directory;
if (ref.name)
strcpy(fref.name, ref.name);
return B_OK;
}
示例6: OpenWorksheet
PDoc* PApp::OpenWorksheet()
{
try
{
if (!gPrefsDir.Contains("Worksheet", B_FILE_NODE | B_SYMLINK_NODE))
{
BFile file;
gPrefsDir.CreateFile("Worksheet", &file);
}
BEntry w;
entry_ref wr;
FailOSErr(gPrefsDir.FindEntry("Worksheet", &w, true));
FailOSErr(w.GetRef(&wr));
OpenWindow(wr);
PDoc *d = dynamic_cast<PDoc*>(CDoc::FindDoc(wr));
if (d)
d->MakeWorksheet();
return d;
}
catch (HErr& e)
{
e.DoError();
}
return NULL;
} /* PApp::OpenWorksheet */
示例7: msg
// Helper function that contacts the registrar for mime update calls
status_t
do_mime_update(int32 what, const char *path, int recursive,
int synchronous, int force)
{
BEntry root;
entry_ref ref;
status_t err = root.SetTo(path ? path : "/");
if (!err)
err = root.GetRef(&ref);
if (!err) {
BMessage msg(what);
BMessage reply;
status_t result;
// Build and send the message, read the reply
if (!err)
err = msg.AddRef("entry", &ref);
if (!err)
err = msg.AddBool("recursive", recursive);
if (!err)
err = msg.AddBool("synchronous", synchronous);
if (!err)
err = msg.AddInt32("force", force);
if (!err)
err = BRoster::Private().SendTo(&msg, &reply, true);
if (!err)
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
if (!err)
err = reply.FindInt32("result", &result);
if (!err)
err = result;
}
return err;
}
示例8: AddEntry
bool SeqNavMenu::AddEntry(BEntry& entry, bool useLeafForLabel)
{
BPath path;
if( entry.GetPath( &path ) != B_OK ) {
printf("\tquery returned an entry but couldn't get the path\n");
return false;
}
const char* label = (useLeafForLabel) ? path.Leaf(): path.Path();
if( !label ) return false;
_AmIconMenuItem* item = 0;
uint32 tmpEntry;
if( entry.IsDirectory() ) {
tmpEntry = DIR_ENTRY;
SeqNavMenu* nm = new SeqNavMenu( label, mTarget );
if( nm && (item = new _AmIconMenuItem( nm )) ) {
nm->SetPath( path.Path() );
}
} else {
tmpEntry = OTHER_ENTRY;
BMessage* msg = new BMessage( B_REFS_RECEIVED );
entry_ref ref;
if( msg && (entry.GetRef( &ref ) == B_OK) ) {
msg->AddRef( "refs", &ref );
item = new _AmIconMenuItem( label, msg );
}
}
if( item ) {
mItems.push_back( item );
item->SetIcon( GetIcon( entry ) );
if( mFirstEntry == NO_ENTRY ) mFirstEntry = tmpEntry;
}
return true;
}
示例9: Archive
status_t HTMLProject::Archive(BMessage *archive,bool deep)
{
archive->AddInt16(hpV,bhv_application); // version
BEntry dirEntry;
entry_ref dirRef;
filesDir.GetEntry(&dirEntry);
dirEntry.GetRef(&dirRef);
archive->AddRef(hpD,&dirRef);
BMallocIO happyArchive;
happyList->Archive(&happyArchive);
archive->AddData(hpH,B_RAW_TYPE,happyArchive.Buffer(),happyArchive.BufferLength());
unsigned int n = fileList->CountItems();
for (unsigned int i=0; i<n; i++)
archive->AddString(hpF,((HTMLFile*)fileList->ItemAt(i))->name.String());
n = labelList->CountItems();
for (unsigned int i=0; i<n; i++)
{
smallLabel *lab = (smallLabel*)labelList->ItemAt(i);
archive->AddString(hpLn,lab->label.String());
archive->AddInt32(hpLf,lab->file);
}
return B_OK;
}
示例10: dir
entry_ref
FindFile(entry_ref folder, const char *name)
{
entry_ref ref,returnRef;
if (!folder.name || !name)
return returnRef;
BDirectory dir(&folder);
if (dir.InitCheck() != B_OK)
return returnRef;
dir.Rewind();
while (dir.GetNextRef(&ref) == B_OK)
{
struct stat statData;
stat(BPath(&ref).Path(),&statData);
// Is a directory?
if (S_ISDIR(statData.st_mode))
{
entry_ref innerref = FindFile(ref,name);
if (innerref.device != -1 && innerref.directory != -1)
return innerref;
}
}
BEntry entry;
if (dir.FindEntry(name,&entry) == B_OK)
entry.GetRef(&returnRef);
return returnRef;
}
示例11: strlen
static int32
build_dirent(const BEntry* source, struct dirent* ent,
size_t size, int32 count)
{
entry_ref ref;
source->GetRef(&ref);
size_t recordLength = strlen(ref.name) + sizeof(dirent);
if (recordLength > size || count <= 0) {
// can't fit in buffer, bail
return 0;
}
// info about this node
ent->d_reclen = static_cast<ushort>(recordLength);
strcpy(ent->d_name, ref.name);
ent->d_dev = ref.device;
ent->d_ino = ref.directory;
// info about the parent
BEntry parent;
source->GetParent(&parent);
if (parent.InitCheck() == B_OK) {
entry_ref parentRef;
parent.GetRef(&parentRef);
ent->d_pdev = parentRef.device;
ent->d_pino = parentRef.directory;
} else {
ent->d_pdev = 0;
ent->d_pino = 0;
}
return 1;
}
示例12: GetAppInfo
void
ServerApp::_LaunchAddOnServer()
{
// Try to launch media_addon_server by mime signature.
// If it fails (for example on the Live CD, where the executable
// hasn't yet been mimesetted), try from this application's
// directory
status_t err = be_roster->Launch(B_MEDIA_ADDON_SERVER_SIGNATURE);
if (err == B_OK)
return;
app_info info;
BEntry entry;
BDirectory dir;
entry_ref ref;
err = GetAppInfo(&info);
err |= entry.SetTo(&info.ref);
err |= entry.GetParent(&entry);
err |= dir.SetTo(&entry);
err |= entry.SetTo(&dir, "media_addon_server");
err |= entry.GetRef(&ref);
if (err == B_OK)
be_roster->Launch(&ref);
if (err == B_OK)
return;
(new BAlert("media_server", "Launching media_addon_server failed.\n\n"
"media_server will terminate", "OK"))->Go();
fprintf(stderr, "Launching media_addon_server (%s) failed: %s\n",
B_MEDIA_ADDON_SERVER_SIGNATURE, strerror(err));
exit(1);
}
示例13: while
void
OpenWindow::CollectDevices(BMenu *menu, BEntry *startEntry)
{
BDirectory directory;
if (startEntry != NULL)
directory.SetTo(startEntry);
else
directory.SetTo("/dev/disk");
BEntry entry;
while (directory.GetNextEntry(&entry) == B_OK) {
if (entry.IsDirectory()) {
CollectDevices(menu, &entry);
continue;
}
entry_ref ref;
if (entry.GetRef(&ref) != B_OK)
continue;
BPath path;
if (entry.GetPath(&path) != B_OK)
continue;
BMessage *message = new BMessage(B_REFS_RECEIVED);
message->AddRef("refs", &ref);
menu->AddItem(new BMenuItem(path.Path(), message));
}
}
示例14: CurrentMessage
void
FileTypes::ArgvReceived(int32 argc, char **argv)
{
BMessage *message = CurrentMessage();
BDirectory currentDirectory;
if (message)
currentDirectory.SetTo(message->FindString("cwd"));
BMessage refs;
for (int i = 1 ; i < argc ; i++) {
BPath path;
if (argv[i][0] == '/')
path.SetTo(argv[i]);
else
path.SetTo(¤tDirectory, argv[i]);
status_t status;
entry_ref ref;
BEntry entry;
if ((status = entry.SetTo(path.Path(), false)) != B_OK
|| (status = entry.GetRef(&ref)) != B_OK) {
fprintf(stderr, "Could not open file \"%s\": %s\n",
path.Path(), strerror(status));
continue;
}
refs.AddRef("refs", &ref);
}
RefsReceived(&refs);
}
示例15: message
void
BNavigator::GoTo()
{
BString pathname = fLocation->Text();
if (pathname.Compare("") == 0)
pathname = "/";
BEntry entry;
entry_ref ref;
if (entry.SetTo(pathname.String()) == B_OK
&& !FSIsDeskDir(&entry)
&& entry.GetRef(&ref) == B_OK) {
BMessage message(kSwitchDirectory);
message.AddRef("refs", &ref);
message.AddInt32("action", kActionLocation);
Window()->PostMessage(&message);
} else {
BPath path;
if (Window()
&& Window()->TargetModel()) {
Window()->TargetModel()->GetPath(&path);
fLocation->SetText(path.Path());
}
}
}