本文整理汇总了C++中BPartition::IsDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ BPartition::IsDevice方法的具体用法?C++ BPartition::IsDevice怎么用?C++ BPartition::IsDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPartition
的用法示例。
在下文中一共展示了BPartition::IsDevice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modificationPreparer
//.........这里部分代码省略.........
BString name;
BString parameters;
// TODO: diskSystem.IsFileSystem() seems like a better fit here?
if (diskSystemName == "Be File System") {
InitParamsPanel* panel = new InitParamsPanel(this, diskSystemName,
partition);
if (panel->Go(name, parameters) == GO_CANCELED)
return;
} else if (diskSystemName == "Intel Partition Map") {
// TODO: parameters?
} else if (diskSystemName == "Intel Extended Partition") {
// TODO: parameters?
}
bool supportsName = diskSystem.SupportsContentName();
BString validatedName(name);
ret = partition->ValidateInitialize(diskSystem.PrettyName(),
supportsName ? &validatedName : NULL, parameters.String());
if (ret != B_OK) {
_DisplayPartitionError(B_TRANSLATE("Validation of the given "
"initialization parameters failed."), partition, ret);
return;
}
BString previousName = partition->ContentName();
ret = partition->Initialize(diskSystem.PrettyName(),
supportsName ? validatedName.String() : NULL, parameters.String());
if (ret != B_OK) {
_DisplayPartitionError(B_TRANSLATE("Initialization of the partition "
"%s failed. (Nothing has been written to disk.)"), partition, ret);
return;
}
// everything looks fine, we are ready to actually write the changes
// to disk
// Warn the user one more time...
if (previousName.Length() > 0) {
if (partition->IsDevice()) {
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
"want to write the changes back to disk now?\n\n"
"All data on the disk %s will be irretrievably lost if you "
"do so!"), previousName.String());
} else {
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
"want to write the changes back to disk now?\n\n"
"All data on the partition %s will be irretrievably lost if you "
"do so!"), previousName.String());
}
} else {
if (partition->IsDevice()) {
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
"want to write the changes back to disk now?\n\n"
"All data on the selected disk will be irretrievably lost if "
"you do so!"));
} else {
snprintf(message, sizeof(message), B_TRANSLATE("Are you sure you "
"want to write the changes back to disk now?\n\n"
"All data on the selected partition will be irretrievably lost "
"if you do so!"));
}
}
alert = new BAlert("final notice", message,
B_TRANSLATE("Write changes"), B_TRANSLATE("Cancel"), NULL,
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
choice = alert->Go();
if (choice == 1)
return;
// commit
ret = modificationPreparer.CommitModifications();
// The partition pointer is toast now! Use the partition ID to
// retrieve it again.
partition = disk->FindDescendant(selectedPartition);
if (ret == B_OK) {
if (diskSystem.IsFileSystem()) {
_DisplayPartitionError(B_TRANSLATE("The partition %s has been "
"successfully formatted.\n"), partition);
} else {
_DisplayPartitionError(B_TRANSLATE("The disk has been "
"successfully initialized.\n"), partition);
}
} else {
if (diskSystem.IsFileSystem()) {
_DisplayPartitionError(B_TRANSLATE("Failed to format the "
"partition %s!\n"), partition, ret);
} else {
_DisplayPartitionError(B_TRANSLATE("Failed to initialize the "
"disk %s!\n"), partition, ret);
}
}
_ScanDrives();
}
示例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 {
//.........这里部分代码省略.........