本文整理汇总了C++中Partition::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ Partition::IsEmpty方法的具体用法?C++ Partition::IsEmpty怎么用?C++ Partition::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Partition
的用法示例。
在下文中一共展示了Partition::IsEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parser
//.........这里部分代码省略.........
// open base device
int baseFD = open(baseDeviceName, O_RDONLY);
if (baseFD < 0) {
fprintf(stderr, "Error: Failed to open \"%s\": %s\n",
baseDeviceName, strerror(errno));
exit(1);
}
// get device size
int64 deviceSize;
if (ioctl(baseFD, DIOCGMEDIASIZE, &deviceSize) == -1) {
fprintf(stderr, "Error: Failed to get device geometry "
"for \"%s\": %s\n", baseDeviceName,
strerror(errno));
exit(1);
}
// parse the partition map
// TODO: block size!
PartitionMapParser parser(baseFD, 0, deviceSize, 512);
PartitionMap map;
error = parser.Parse(NULL, &map);
if (error != B_OK) {
fprintf(stderr, "Error: Parsing partition table on "
"device \"%s\" failed: %s\n", baseDeviceName,
strerror(error));
exit(1);
}
close(baseFD);
// check the partition we are supposed to write at
Partition *partition = map.PartitionAt(partitionIndex - 1);
if (!partition || partition->IsEmpty()) {
fprintf(stderr, "Error: Invalid partition index %d.\n",
partitionIndex);
dump_partition_map(map);
exit(1);
}
if (partition->IsExtended()) {
fprintf(stderr, "Error: Partition %d is an extended "
"partition.\n", partitionIndex);
dump_partition_map(map);
exit(1);
}
partitionOffset = partition->Offset();
} else {
// The given device is the base device. We'll write at
// offset 0.
}
#endif // ANTARES_HOST_PLATFORM_FREEBSD
} else if (S_ISBLK(st.st_mode)) {
// block device: a device or partition under Linux or Darwin
#ifdef ANTARES_HOST_PLATFORM_LINUX
// chop off the trailing number
int fileNameLen = strlen(fileName);
int baseNameLen = -1;
for (int k = fileNameLen - 1; k >= 0; k--) {
if (!isdigit(fileName[k])) {
baseNameLen = k + 1;