本文整理汇总了C++中BPartition::ID方法的典型用法代码示例。如果您正苦于以下问题:C++ BPartition::ID方法的具体用法?C++ BPartition::ID怎么用?C++ BPartition::ID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPartition
的用法示例。
在下文中一共展示了BPartition::ID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CountChildren
// _RemoveObsoleteDescendants
status_t
BPartition::_RemoveObsoleteDescendants(user_partition_data* data, bool* updated)
{
// remove all children not longer persistent
// Not exactly efficient: O(n^2), considering BList::RemoveItem()
// O(1). We could do better (O(n*log(n))), when sorting the arrays before,
// but then the list access is more random and we had to find the
// BPartition to remove, which makes the list operation definitely O(n).
int32 count = CountChildren();
for (int32 i = count - 1; i >= 0; i--) {
BPartition* child = ChildAt(i);
bool found = false;
for (int32 k = data->child_count - 1; k >= 0; k--) {
if (data->children[k]->id == child->ID()) {
// found partition: ask it to remove its obsolete descendants
found = true;
status_t error = child->_RemoveObsoleteDescendants(
data->children[k], updated);
if (error != B_OK)
return error;
// set the user data to the BPartition object to find it
// quicker later
data->children[k]->user_data = child;
break;
}
}
// if partition is obsolete, remove it
if (!found) {
*updated = true;
_RemoveChild(i);
}
}
return B_OK;
}
示例2: mountFlagsKey
virtual bool
Visit(BPartition* partition, int32 level)
{
if (fOnlyOnDeviceID >= 0) {
// only mount partitions on the given device id
// or if the partition ID is already matched
BPartition* device = partition;
while (device->Parent() != NULL) {
if (device->ID() == fOnlyOnDeviceID) {
// we are happy
break;
}
device = device->Parent();
}
if (device->ID() != fOnlyOnDeviceID)
return false;
}
mount_mode mode = !fInitialRescan
&& partition->Device()->IsRemovableMedia()
? fRemovableMode : fNormalMode;
if (mode == kNoVolumes
|| partition->IsMounted()
|| !partition->ContainsFileSystem())
return false;
BPath path;
if (partition->GetPath(&path) != B_OK)
return false;
if (mode == kRestorePreviousVolumes) {
// mount all volumes that were stored in the settings file
const char *volumeName = NULL;
if (partition->ContentName() == NULL
|| fPrevious.FindString(path.Path(), &volumeName)
!= B_OK
|| strcmp(volumeName, partition->ContentName()))
return false;
} else if (mode == kOnlyBFSVolumes) {
if (partition->ContentType() == NULL
|| strcmp(partition->ContentType(), kPartitionTypeBFS))
return false;
}
uint32 mountFlags;
if (!fInitialRescan) {
// Ask the user about mount flags if this is not the
// initial scan.
if (!_SuggestMountFlags(partition, &mountFlags))
return false;
} else {
BString mountFlagsKey(path.Path());
mountFlagsKey << kMountFlagsKeyExtension;
if (fPrevious.FindInt32(mountFlagsKey.String(),
(int32*)&mountFlags) < B_OK) {
mountFlags = 0;
}
}
if (partition->Mount(NULL, mountFlags) != B_OK) {
// TODO: Error to syslog
}
return false;
}