本文整理汇总了C++中BPartition::DeleteChild方法的典型用法代码示例。如果您正苦于以下问题:C++ BPartition::DeleteChild方法的具体用法?C++ BPartition::DeleteChild怎么用?C++ BPartition::DeleteChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPartition
的用法示例。
在下文中一共展示了BPartition::DeleteChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modificationPreparer
void
MainWindow::_Delete(BDiskDevice* disk, partition_id selectedPartition)
{
if (!disk || selectedPartition < 0) {
_DisplayPartitionError(B_TRANSLATE("You need to select a partition "
"entry from the list."));
return;
}
if (disk->IsReadOnly()) {
_DisplayPartitionError(B_TRANSLATE("The selected disk is read-only."));
return;
}
BPartition* partition = disk->FindDescendant(selectedPartition);
if (!partition) {
_DisplayPartitionError(B_TRANSLATE("Unable to find the selected "
"partition by ID."));
return;
}
BPartition* parent = partition->Parent();
if (!parent) {
_DisplayPartitionError(B_TRANSLATE("The currently selected partition "
"does not have a parent partition."));
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;
}
if (!parent->CanDeleteChild(partition->Index())) {
_DisplayPartitionError(
B_TRANSLATE("Cannot delete the selected partition."));
return;
}
// Warn the user one more time...
BAlert* alert = new BAlert("final notice", B_TRANSLATE("Are you sure you "
"want to delete the selected partition?\n\n"
"All data on the partition will be irretrievably lost if you "
"do so!"), B_TRANSLATE("Delete partition"), B_TRANSLATE("Cancel"), NULL,
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
int32 choice = alert->Go();
if (choice == 1)
return;
ret = parent->DeleteChild(partition->Index());
if (ret != B_OK) {
_DisplayPartitionError(
B_TRANSLATE("Could not delete the selected partition."));
return;
}
ret = modificationPreparer.CommitModifications();
if (ret != B_OK) {
_DisplayPartitionError(B_TRANSLATE("Failed to delete the partition. "
"No changes have been written to disk."));
return;
}
_ScanDrives();
fDiskView->ForceUpdate();
}