本文整理汇总了C++中BEntry::SetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::SetTo方法的具体用法?C++ BEntry::SetTo怎么用?C++ BEntry::SetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEntry
的用法示例。
在下文中一共展示了BEntry::SetTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3:
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;
}
示例4: 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;
}
示例5: 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();
}
示例6: if
status_t
InstalledPackageInfo::Uninstall()
{
if (fStatus != B_OK)
return fStatus;
BString *iter;
uint32 i, count = fInstalledItems.CountItems();
BEntry entry;
status_t ret;
// Try to remove all entries that are present in the list
for (i = 0; i < count; i++) {
iter = static_cast<BString *>(fInstalledItems.ItemAt(count - i - 1));
fprintf(stderr, "Removing: %s (%ld/%ld)\n", iter->String(), i, count);
ret = entry.SetTo(iter->String());
if (ret == B_BUSY) {
// The entry's directory is locked - wait a few cycles for it to
// unlock itself
int32 tries = 0;
for (tries = 0; tries < P_BUSY_TRIES; tries++) {
ret = entry.SetTo(iter->String());
if (ret != B_BUSY)
break;
// Wait a moment
usleep(1000);
}
}
if (ret == B_ENTRY_NOT_FOUND)
continue;
else if (ret != B_OK) {
fStatus = B_ERROR;
return fStatus;
}
fprintf(stderr, "...we continue\n");
if (entry.Exists() && entry.Remove() != B_OK) {
fprintf(stderr, "\n%s\n", strerror(ret));
fStatus = B_ERROR;
return fStatus;
}
fInstalledItems.RemoveItem(count - i - 1);
}
if (entry.SetTo(fPathToInfo.Path()) != B_OK) {
fStatus = B_ERROR;
return fStatus;
}
if (entry.Exists() && entry.Remove() != B_OK) {
fStatus = B_ERROR;
return fStatus;
}
return fStatus;
}
示例7: MessageReceived
void CPathsBox::MessageReceived(BMessage *msg)
{
try
{
entry_ref ref;
BEntry e;
BPath p;
if (msg->WasDropped() && msg->HasRef("refs"))
{
FailOSErr(msg->FindRef("refs", &ref));
FailOSErr(e.SetTo(&ref));
FailOSErr(e.GetPath(&p));
fList->AddItem(new BStringItem(p.Path()));
ListBoxChanged();
}
else switch (msg->what)
{
case msg_AddPath:
case msg_ChangePath:
FailOSErr(msg->FindRef("refs", &ref));
FailOSErr(e.SetTo(&ref));
FailOSErr(e.GetPath(&p));
if (msg->what == msg_AddPath)
fList->AddItem(new BStringItem(p.Path()));
else
{
BStringItem *item;
FailOSErr(msg->FindPointer("item", (void**)&item));
if (fList->IndexOf(item) < 0)
THROW(("item was removed from list!"));
item->SetText(p.Path());
}
delete fPanel;
fPanel = NULL;
ListBoxChanged();
break;
default:
CListBox::MessageReceived(msg);
break;
}
}
catch (HErr& e)
{
e.DoError();
}
} /* CPathsBox::MessageReceived */
示例8:
status_t
ZKWindow::MakeSettingsFolder (void)
{
PRINT(("ZKWindow::MakeSettingsFolder()\n"));
status_t status;
BPath path;
if ((status = find_directory(B_USER_SETTINGS_DIRECTORY, & path)) != B_OK)
return status;
BEntry entry (path.Path());
// settings
if (entry.Exists() == false || entry.IsDirectory() == false)
return B_ERROR;
BDirectory mother (path.Path());
BDirectory baby;
// Kirilla
path.SetTo(path.Path(), "Kirilla");
entry.SetTo(path.Path());
if (! entry.Exists())
{
status = mother.CreateDirectory("Kirilla", & baby);
if (status != B_OK && status != B_FILE_EXISTS) return status;
}
else
if (! entry.IsDirectory())
return B_FILE_EXISTS;
if ((status = mother.SetTo(path.Path())) != B_OK) return status;
// ZooKeeper
path.SetTo(path.Path(), "ZooKeeper");
entry.SetTo(path.Path());
if (! entry.Exists())
{
status = mother.CreateDirectory("ZooKeeper", & baby);
if (status != B_OK && status != B_FILE_EXISTS) return status;
}
else
if (! entry.IsDirectory())
return B_FILE_EXISTS;
if ((status = mother.SetTo(path.Path())) != B_OK) return status;
entry.SetTo(path.Path());
if (entry.Exists() && entry.IsDirectory()) return B_OK;
else return B_ERROR;
}
示例9: sizeof
/*! \brief Sets the name of the volume referred to by this object.
\param name The volume's new name. Must not be longer than
\c B_FILE_NAME_LENGTH (including the terminating null).
\return
- \c B_OK: Everything went fine.
- \c B_BAD_VALUE: \c NULL \a name or the object is not properly
initialized.
- another error code
*/
status_t
BVolume::SetName(const char *name)
{
// check initialization
if (!name || InitCheck() != B_OK)
return B_BAD_VALUE;
if (strlen(name) >= B_FILE_NAME_LENGTH)
return B_NAME_TOO_LONG;
// get the FS stat (including the old name) first
fs_info oldInfo;
if (fs_stat_dev(fDevice, &oldInfo) != 0)
return errno;
if (strcmp(name, oldInfo.volume_name) == 0)
return B_OK;
// set the volume name
fs_info newInfo;
strlcpy(newInfo.volume_name, name, sizeof(newInfo.volume_name));
status_t error = _kern_write_fs_info(fDevice, &newInfo,
FS_WRITE_FSINFO_NAME);
if (error != B_OK)
return error;
// change the name of the mount point
// R5 implementation checks, if an entry with the volume's old name
// exists in the root directory and renames that entry, if it is indeed
// the mount point of the volume (or a link referring to it). In all other
// cases, nothing is done (even if the mount point is named like the
// volume, but lives in a different directory).
// We follow suit for the time being.
// NOTE: If the volume name itself is actually "boot", then this code
// tries to rename /boot, but that is prevented in the kernel.
BPath entryPath;
BEntry entry;
BEntry traversedEntry;
node_ref entryNodeRef;
if (BPrivate::Storage::check_entry_name(name) == B_OK
&& BPrivate::Storage::check_entry_name(oldInfo.volume_name) == B_OK
&& entryPath.SetTo("/", oldInfo.volume_name) == B_OK
&& entry.SetTo(entryPath.Path(), false) == B_OK
&& entry.Exists()
&& traversedEntry.SetTo(entryPath.Path(), true) == B_OK
&& traversedEntry.GetNodeRef(&entryNodeRef) == B_OK
&& entryNodeRef.device == fDevice
&& entryNodeRef.node == oldInfo.root) {
entry.Rename(name, false);
}
return error;
}
示例10: path
status_t
ScreenshotWindow::_SaveScreenshot()
{
if (!fScreenshot || !fLastSelectedPath)
return B_ERROR;
BPath path(_GetDirectory());
if (path == NULL)
return B_ERROR;
path.Append(fNameControl->Text());
BEntry entry;
entry.SetTo(path.Path());
if (entry.Exists()) {
BAlert* overwriteAlert = new BAlert(
B_TRANSLATE("overwrite"),
B_TRANSLATE("This file already exists.\n Are you sure you would "
"like to overwrite it?"),
B_TRANSLATE("Cancel"),
B_TRANSLATE("Overwrite"),
NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
overwriteAlert->SetShortcut(0, B_ESCAPE);
if (overwriteAlert->Go() == 0)
return B_CANCELED;
}
return fUtility.Save(fScreenshot, path.Path(), fImageFileType);
}
示例11: Probe
void
DiskProbe::RefsReceived(BMessage* message)
{
bool traverseLinks = (modifiers() & B_SHIFT_KEY) == 0;
int32 index = 0;
entry_ref ref;
while (message->FindRef("refs", index++, &ref) == B_OK) {
const char* attribute = NULL;
if (message->FindString("attributes", index - 1, &attribute) == B_OK)
traverseLinks = false;
BEntry entry;
status_t status = entry.SetTo(&ref, traverseLinks);
if (status == B_OK)
status = Probe(entry, attribute);
if (status != B_OK) {
char buffer[1024];
snprintf(buffer, sizeof(buffer),
B_TRANSLATE_COMMENT("Could not open \"%s\":\n"
"%s", "Opening of entry reference buffer for a DiskProbe "
"request Alert message. The name of entry reference and "
"error message is shown."),
ref.name, strerror(status));
BAlert* alert = new BAlert(B_TRANSLATE("DiskProbe request"),
buffer, B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
}
}
}
示例12: startModel
bool
BNavMenu::StartBuildingItemList()
{
BEntry entry;
if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK
|| !entry.Exists())
return false;
fItemList = new BObjectList<BMenuItem>(50);
fIteratingDesktop = false;
BDirectory parent;
status_t status = entry.GetParent(&parent);
// if ref is the root item then build list of volume root dirs
fFlags = uint8((fFlags & ~kVolumesOnly) | (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
if (fFlags & kVolumesOnly)
return true;
Model startModel(&entry, true);
if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
return false;
if (startModel.IsQuery())
fContainer = new QueryEntryListCollection(&startModel);
else if (FSIsDeskDir(&entry)) {
fIteratingDesktop = true;
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
AddRootItemsIfNeeded();
} else if (FSIsTrashDir(&entry)) {
// the trash window needs to display a union of all the
// trash folders from all the mounted volumes
BVolumeRoster volRoster;
volRoster.Rewind();
BVolume volume;
fContainer = new EntryIteratorList();
while (volRoster.GetNextVolume(&volume) == B_OK) {
if (!volume.IsPersistent())
continue;
BDirectory trashDir;
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK)
dynamic_cast<EntryIteratorList *>(fContainer)->
AddItem(new DirectoryEntryList(trashDir));
}
} else
fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory *>
(startModel.Node()));
if (fContainer == NULL || fContainer->InitCheck() != B_OK)
return false;
fContainer->Rewind();
return true;
}
示例13: 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());
}
}
}
示例14: name
BEntry
MediaConverterApp::_CreateOutputFile(BDirectory directory,
entry_ref* ref, media_file_format* outputFormat)
{
BString name(ref->name);
// create output file name
int32 extIndex = name.FindLast('.');
if (extIndex != B_ERROR)
name.Truncate(extIndex + 1);
else
name.Append(".");
name.Append(outputFormat->file_extension);
BEntry inEntry(ref);
BEntry outEntry;
if (inEntry.InitCheck() == B_OK) {
// ensure that output name is unique
int32 len = name.Length();
int32 i = 1;
while (directory.Contains(name.String())) {
name.Truncate(len);
name << " " << i;
i++;
}
outEntry.SetTo(&directory, name.String());
}
return outEntry;
}
示例15: while
void
Debugger::RefsReceived(BMessage *message)
{
int32 index = 0;
entry_ref ref;
while (message->FindRef("refs", index++, &ref) == B_OK) {
BEntry entry;
status_t status = entry.SetTo(&ref);
if (status == B_OK)
status = Debug(entry);
if (status != B_OK) {
char buffer[1024];
snprintf(buffer, sizeof(buffer),
"Could not debug \"%s\":\n"
"%s",
ref.name, strerror(status));
(new BAlert("Debugger request",
buffer, "OK", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
}
}
}