本文整理汇总了C++中BPartition::GetVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ BPartition::GetVolume方法的具体用法?C++ BPartition::GetVolume怎么用?C++ BPartition::GetVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPartition
的用法示例。
在下文中一共展示了BPartition::GetVolume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CALLED
void
WorkerThread::_PerformInstall(BMenu* srcMenu, BMenu* targetMenu)
{
CALLED();
BPath targetDirectory;
BPath srcDirectory;
BPath trashPath;
BPath testPath;
BDirectory targetDir;
BDiskDevice device;
BPartition* partition;
BVolume targetVolume;
status_t err = B_OK;
int32 entries = 0;
entry_ref testRef;
const char* mountError = B_TRANSLATE("The disk can't be mounted. Please "
"choose a different disk.");
BMessenger messenger(fWindow);
ProgressReporter reporter(messenger, new BMessage(MSG_STATUS_MESSAGE));
CopyEngine engine(&reporter);
BList unzipEngines;
PartitionMenuItem* targetItem = (PartitionMenuItem*)targetMenu->FindMarked();
PartitionMenuItem* srcItem = (PartitionMenuItem*)srcMenu->FindMarked();
if (!srcItem || !targetItem) {
ERR("bad menu items\n");
goto error;
}
// check if target is initialized
// ask if init or mount as is
if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device,
&partition) == B_OK) {
if (!partition->IsMounted()) {
if ((err = partition->Mount()) < B_OK) {
_SetStatusMessage(mountError);
ERR("BPartition::Mount");
goto error;
}
}
if ((err = partition->GetVolume(&targetVolume)) != B_OK) {
ERR("BPartition::GetVolume");
goto error;
}
if ((err = partition->GetMountPoint(&targetDirectory)) != B_OK) {
ERR("BPartition::GetMountPoint");
goto error;
}
} else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) {
if (!device.IsMounted()) {
if ((err = device.Mount()) < B_OK) {
_SetStatusMessage(mountError);
ERR("BDiskDevice::Mount");
goto error;
}
}
if ((err = device.GetVolume(&targetVolume)) != B_OK) {
ERR("BDiskDevice::GetVolume");
goto error;
}
if ((err = device.GetMountPoint(&targetDirectory)) != B_OK) {
ERR("BDiskDevice::GetMountPoint");
goto error;
}
} else
goto error; // shouldn't happen
// check if target has enough space
if ((fSpaceRequired > 0 && targetVolume.FreeBytes() < fSpaceRequired)
&& ((new BAlert("", B_TRANSLATE("The destination disk may not have "
"enough space. Try choosing a different disk or choose to not "
"install optional items."), B_TRANSLATE("Try installing anyway"),
B_TRANSLATE("Cancel"), 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
goto error;
}
if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) {
if ((err = partition->GetMountPoint(&srcDirectory)) != B_OK) {
ERR("BPartition::GetMountPoint");
goto error;
}
} else if (fDDRoster.GetDeviceWithID(srcItem->ID(), &device) == B_OK) {
if ((err = device.GetMountPoint(&srcDirectory)) != B_OK) {
ERR("BDiskDevice::GetMountPoint");
goto error;
}
} else
goto error; // shouldn't happen
// check not installing on itself
if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) {
_SetStatusMessage(B_TRANSLATE("You can't install the contents of a "
"disk onto itself. Please choose a different disk."));
goto error;
}
// check not installing on boot volume
//.........这里部分代码省略.........
示例2: BMessage
void
MainWindow::_UpdateMenus(BDiskDevice* disk,
partition_id selectedPartition, partition_id parentID)
{
while (BMenuItem* item = fFormatMenu->RemoveItem(0L))
delete item;
while (BMenuItem* item = fDiskInitMenu->RemoveItem(0L))
delete item;
fCreateMI->SetEnabled(false);
fUnmountMI->SetEnabled(false);
fDiskInitMenu->SetEnabled(false);
fFormatMenu->SetEnabled(false);
if (!disk) {
fWipeMI->SetEnabled(false);
fEjectMI->SetEnabled(false);
fSurfaceTestMI->SetEnabled(false);
} else {
// fWipeMI->SetEnabled(true);
fWipeMI->SetEnabled(false);
fEjectMI->SetEnabled(disk->IsRemovableMedia());
// fSurfaceTestMI->SetEnabled(true);
fSurfaceTestMI->SetEnabled(false);
// Create menu and items
BPartition* parentPartition = NULL;
if (selectedPartition <= -2) {
// a partitionable space item is selected
parentPartition = disk->FindDescendant(parentID);
}
if (parentPartition && parentPartition->ContainsPartitioningSystem())
fCreateMI->SetEnabled(true);
bool prepared = disk->PrepareModifications() == B_OK;
fFormatMenu->SetEnabled(prepared);
fDeleteMI->SetEnabled(prepared);
BPartition* partition = disk->FindDescendant(selectedPartition);
BDiskSystem diskSystem;
fDDRoster.RewindDiskSystems();
while (fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) {
if (!diskSystem.SupportsInitializing())
continue;
BMessage* message = new BMessage(MSG_INITIALIZE);
message->AddInt32("parent id", parentID);
message->AddString("disk system", diskSystem.PrettyName());
BString label = diskSystem.PrettyName();
label << B_UTF8_ELLIPSIS;
BMenuItem* item = new BMenuItem(label.String(), message);
// TODO: Very unintuitive that we have to use PrettyName (vs Name)
item->SetEnabled(partition != NULL
&& partition->CanInitialize(diskSystem.PrettyName()));
if (disk->ID() == selectedPartition
&& !diskSystem.IsFileSystem()) {
// Disk is selected, and DiskSystem is a partition map
fDiskInitMenu->AddItem(item);
} else if (diskSystem.IsFileSystem()) {
// Otherwise a filesystem
fFormatMenu->AddItem(item);
}
}
// Mount items
if (partition) {
fFormatMenu->SetEnabled(!partition->IsMounted()
&& !partition->IsReadOnly()
&& partition->Device()->HasMedia()
&& fFormatMenu->CountItems() > 0);
fDiskInitMenu->SetEnabled(!partition->IsMounted()
&& !partition->IsReadOnly()
&& partition->Device()->HasMedia()
&& partition->IsDevice()
&& fDiskInitMenu->CountItems() > 0);
fDeleteMI->SetEnabled(!partition->IsMounted()
&& !partition->IsDevice());
fMountMI->SetEnabled(!partition->IsMounted());
bool unMountable = false;
if (partition->IsMounted()) {
// see if this partition is the boot volume
BVolume volume;
BVolume bootVolume;
if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK
&& partition->GetVolume(&volume) == B_OK) {
unMountable = volume != bootVolume;
} else
unMountable = true;
}
fUnmountMI->SetEnabled(unMountable);
} else {
//.........这里部分代码省略.........