本文整理汇总了C++中BVolume::SetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BVolume::SetTo方法的具体用法?C++ BVolume::SetTo怎么用?C++ BVolume::SetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BVolume
的用法示例。
在下文中一共展示了BVolume::SetTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Feeder::HandleDeviceUpdate(BMessage *message)
{
int32 opcode ;
BVolume *volume = new BVolume ;
dev_t device ;
message->FindInt32("opcode", &opcode) ;
switch (opcode) {
case B_DEVICE_MOUNTED :
message->FindInt32("new device", &device) ;
volume->SetTo(device) ;
AddQuery(volume) ;
// Forward the message to Indexer so that it can spawn
// a new thread for volume.
be_app->PostMessage(message) ;
break ;
case B_DEVICE_UNMOUNTED :
message->FindInt32("device", &device) ;
volume->SetTo(device) ;
RemoveQuery(volume) ;
be_app->PostMessage(message) ;
break ;
}
delete volume ;
}
示例2: PoseView
void
BVolumeWindow::MenusBeginning()
{
_inherited::MenusBeginning();
if (!fMenuBar)
return;
BVolume boot;
BVolumeRoster().GetBootVolume(&boot);
bool ejectableVolumeSelected = false;
int32 count = PoseView()->SelectionList()->CountItems();
for (int32 index = 0; index < count; index++) {
Model *model = PoseView()->SelectionList()->ItemAt(index)->TargetModel();
if (model->IsVolume()) {
BVolume volume;
volume.SetTo(model->NodeRef()->device);
if (volume != boot) {
ejectableVolumeSelected = true;
break;
}
}
}
BMenuItem* item = fMenuBar->FindItem(kUnmountVolume);
if (item)
item->SetEnabled(ejectableVolumeSelected);
}
示例3: IsDirReadOnly
bool GenesisCopyWindow::IsDirReadOnly(const char *destination)
////////////////////////////////////////////////////////////////////////
{
struct stat statbuf;
BDirectory dir(destination);
BVolume volume;
if (dir.InitCheck()!=B_OK)
return false;
if (dir.GetStatFor(destination, &statbuf)!=B_OK)
return false;
volume.SetTo(statbuf.st_dev);
if (volume.IsReadOnly())
return true;
return false; // Not read only
}
示例4:
// TestDirectories
static
void
TestDirectories(dev_t device)
{
BVolume volume;
if (device >= 0)
CPPUNIT_ASSERT( volume.SetTo(device) == B_OK );
for (int32 i = 0; i < directoryCount; i++) {
BPath path;
BPath path2;
char path3[B_PATH_NAME_LENGTH + 1];
status_t result = test_find_directory(directories[i], path, device);
status_t result2 = find_directory(directories[i], &path2, false,
&volume);
status_t result3 = find_directory(directories[i], device, false,
path3, B_PATH_NAME_LENGTH + 1);
CPPUNIT_ASSERT( result == result2 && result == result3 );
if (result == B_OK)
CPPUNIT_ASSERT( path == path2 && path == path3 );
}
}
示例5: BMessage
status_t
PackageView::_InstallTypeChanged(int32 index)
{
if (index < 0)
return B_ERROR;
// Clear the choice list
for (int32 i = fDestination->CountItems() - 1; i >= 0; i--) {
BMenuItem* item = fDestination->RemoveItem(i);
delete item;
}
fCurrentType = index;
pkg_profile* profile = fInfo.GetProfile(index);
if (profile == NULL)
return B_ERROR;
BString typeDescription = profile->description;
if (typeDescription.IsEmpty())
typeDescription = profile->name;
fInstallTypeDescriptionView->SetText(typeDescription.String());
BPath path;
BVolume volume;
if (profile->path_type == P_INSTALL_PATH) {
BMenuItem* item = NULL;
if (find_directory(B_SYSTEM_NONPACKAGED_DIRECTORY, &path) == B_OK) {
dev_t device = dev_for_path(path.Path());
if (volume.SetTo(device) == B_OK && !volume.IsReadOnly()
&& path.Append("apps") == B_OK) {
item = _AddDestinationMenuItem(path.Path(), volume.FreeBytes(),
path.Path());
}
}
if (item != NULL) {
item->SetMarked(true);
fCurrentPath.SetTo(path.Path());
fDestination->AddSeparatorItem();
}
_AddMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
new BMessage(P_MSG_OPEN_PANEL), fDestination);
fDestField->SetEnabled(true);
} else if (profile->path_type == P_USER_PATH) {
bool defaultPathSet = false;
BVolumeRoster roster;
while (roster.GetNextVolume(&volume) != B_BAD_VALUE) {
BDirectory mountPoint;
if (volume.IsReadOnly() || !volume.IsPersistent()
|| volume.GetRootDirectory(&mountPoint) != B_OK) {
continue;
}
if (path.SetTo(&mountPoint, NULL) != B_OK)
continue;
char volumeName[B_FILE_NAME_LENGTH];
volume.GetName(volumeName);
BMenuItem* item = _AddDestinationMenuItem(volumeName,
volume.FreeBytes(), path.Path());
// The first volume becomes the default element
if (!defaultPathSet) {
item->SetMarked(true);
fCurrentPath.SetTo(path.Path());
defaultPathSet = true;
}
}
fDestField->SetEnabled(true);
} else
fDestField->SetEnabled(false);
return B_OK;
}
示例6: VolRootMessage
bool
FolderShaper::IsFolderUntouchable(uint32 purpose, const entry_ref * a_ref)
{
// system directories
if (IsItThisFolder(a_ref, B_DESKTOP_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_TRASH_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_APPS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_PREFERENCES_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_SYSTEM_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_ADDONS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_BOOT_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_FONTS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_LIB_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_SERVERS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_APPS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_BIN_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_ETC_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_DOCUMENTATION_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_BEOS_PREFERENCES_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_ADDONS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_BOOT_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_FONTS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_LIB_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_SERVERS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_BIN_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_ETC_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_DOCUMENTATION_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_SETTINGS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_DEVELOP_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_LOG_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_SPOOL_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_TEMP_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_SYSTEM_VAR_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_CONFIG_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_ADDONS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_BOOT_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_FONTS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_LIB_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_SETTINGS_DIRECTORY)) return SysDirMessage(a_ref);
if (IsItThisFolder(a_ref, B_USER_DESKBAR_DIRECTORY)) return SysDirMessage(a_ref);
// volume roots
BVolumeRoster vol_roster;
BVolume volume;
BDirectory vol_dir;
BEntry vol_entry;
entry_ref vol_ref;
while (vol_roster.GetNextVolume(& volume) == B_OK)
{
volume.GetRootDirectory(& vol_dir);
vol_dir.GetEntry(& vol_entry);
vol_entry.GetRef(& vol_ref);
if (*a_ref == vol_ref)
return VolRootMessage(a_ref);
}
// target does not support attributes
if (volume.SetTo(a_ref->device) != B_OK)
{
// message
return true;
}
if(! volume.KnowsAttr())
{
char volname[B_FILE_NAME_LENGTH];
volume.GetName(volname);
return NoAttributesMessage(purpose, a_ref, volname);
}
// and perhaps returns something for the BAlert
return false;
}