本文整理汇总了C++中BPartition::ContainsPartitioningSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ BPartition::ContainsPartitioningSystem方法的具体用法?C++ BPartition::ContainsPartitioningSystem怎么用?C++ BPartition::ContainsPartitioningSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPartition
的用法示例。
在下文中一共展示了BPartition::ContainsPartitioningSystem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modificationPreparer
void
MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition)
{
if (!disk || selectedPartition > -2) {
_DisplayPartitionError(B_TRANSLATE("The currently selected partition "
"is not empty."));
return;
}
if (disk->IsReadOnly()) {
_DisplayPartitionError(B_TRANSLATE("The selected disk is read-only."));
return;
}
PartitionListRow* currentSelection = dynamic_cast<PartitionListRow*>(
fListView->CurrentSelection());
if (!currentSelection) {
_DisplayPartitionError(B_TRANSLATE("There was an error acquiring the "
"partition row."));
return;
}
BPartition* parent = disk->FindDescendant(currentSelection->ParentID());
if (!parent) {
_DisplayPartitionError(B_TRANSLATE("The currently selected partition "
"does not have a parent partition."));
return;
}
if (!parent->ContainsPartitioningSystem()) {
_DisplayPartitionError(B_TRANSLATE("The selected partition does not "
"contain a partitioning system."));
return;
}
ModificationPreparer modificationPreparer(disk);
status_t ret = modificationPreparer.ModificationStatus();
if (ret != B_OK) {
_DisplayPartitionError(B_TRANSLATE("There was an error preparing the "
"disk for modifications."), NULL, ret);
return;
}
// get partitioning info
BPartitioningInfo partitioningInfo;
status_t error = parent->GetPartitioningInfo(&partitioningInfo);
if (error != B_OK) {
_DisplayPartitionError(B_TRANSLATE("Could not aquire partitioning "
"information."));
return;
}
int32 spacesCount = partitioningInfo.CountPartitionableSpaces();
if (spacesCount == 0) {
_DisplayPartitionError(B_TRANSLATE("There's no space on the partition "
"where a child partition could be created."));
return;
}
BString name, type, parameters;
off_t offset = currentSelection->Offset();
off_t size = currentSelection->Size();
CreateParamsPanel* panel = new CreateParamsPanel(this, parent, offset,
size);
if (panel->Go(offset, size, name, type, parameters) == GO_CANCELED)
return;
ret = parent->ValidateCreateChild(&offset, &size, type.String(),
&name, parameters.String());
if (ret != B_OK) {
_DisplayPartitionError(B_TRANSLATE("Validation of the given creation "
"parameters failed."));
return;
}
// Warn the user one more time...
BAlert* alert = new BAlert("final notice", B_TRANSLATE("Are you sure you "
"want to write the changes back to disk now?\n\n"
"All data on the partition will be irretrievably lost if you do "
"so!"), B_TRANSLATE("Write changes"), B_TRANSLATE("Cancel"), NULL,
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
int32 choice = alert->Go();
if (choice == 1)
return;
ret = parent->CreateChild(offset, size, type.String(),
name.String(), parameters.String());
if (ret != B_OK) {
_DisplayPartitionError(B_TRANSLATE("Creation of the partition has "
"failed."));
return;
}
// commit
ret = modificationPreparer.CommitModifications();
//.........这里部分代码省略.........
示例2: _NewPartition
void _NewPartition()
{
if (!fPrepared) {
if (fDevice->IsReadOnly())
printf("Device is read-only!\n");
else
printf("Sorry, not prepared for modifications!\n");
return;
}
// get the parent partition
BPartition* partition = NULL;
int32 partitionIndex;
if (!_SelectPartition("parent partition index [-1 to abort]: ",
partition, partitionIndex)) {
return;
}
printf("\nselected partition:\n\n");
print_partition_table_header();
print_partition(partition, 0, partitionIndex);
if (!partition->ContainsPartitioningSystem()) {
printf("The selected partition does not contain a partitioning "
"system.\n");
return;
}
// get supported types
BObjectList<BString> supportedTypes(20, true);
BString typeBuffer;
int32 cookie = 0;
while (partition->GetNextSupportedChildType(&cookie, &typeBuffer)
== B_OK) {
supportedTypes.AddItem(new BString(typeBuffer));
}
if (supportedTypes.IsEmpty()) {
printf("The partitioning system is not able to create any "
"child partition (no supported types).\n");
return;
}
// get partitioning info
BPartitioningInfo partitioningInfo;
status_t error = partition->GetPartitioningInfo(&partitioningInfo);
if (error != B_OK) {
printf("Failed to get partitioning info for partition: %s\n",
strerror(error));
return;
}
int32 spacesCount = partitioningInfo.CountPartitionableSpaces();
if (spacesCount == 0) {
printf("There's no space on the partition where a child partition "
"could be created\n");
return;
}
// let the user select the partition type, if there's more than one
int64 typeIndex = 0;
int32 supportedTypesCount = supportedTypes.CountItems();
if (supportedTypesCount > 1) {
// list them
printf("Possible partition types:\n");
for (int32 i = 0; i < supportedTypesCount; i++)
printf("%2ld %s\n", i, supportedTypes.ItemAt(i)->String());
if (!_ReadNumber("supported type index [-1 to abort]: ", 0,
supportedTypesCount - 1, -1, "invalid index", typeIndex)) {
return;
}
}
const char* type = supportedTypes.ItemAt(typeIndex)->String();
// list partitionable spaces
printf("Unused regions where the new partition could be created:\n");
for (int32 i = 0; i < spacesCount; i++) {
off_t _offset;
off_t _size;
partitioningInfo.GetPartitionableSpaceAt(i, &_offset, &_size);
BString offset, size;
get_size_string(_offset, offset);
get_size_string(_size, size);
printf("%2ld start: %8s, size: %8s\n", i, offset.String(),
size.String());
}
// let the user select the partitionable space, if there's more than one
int64 spaceIndex = 0;
if (spacesCount > 1) {
if (!_ReadNumber("unused region index [-1 to abort]: ", 0,
spacesCount - 1, -1, "invalid index", spaceIndex)) {
return;
}
}
off_t spaceOffset;
off_t spaceSize;
//.........这里部分代码省略.........
示例3: 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 {
//.........这里部分代码省略.........