Exemplo n.º 1
0
EsmFile::EsmFile(const std::string& filename)
{
	file = getFilesystem()->fileOpen(filename);

	while (!file->eof()) {
		records.insert(new EsmRecord(file));
	}
	nRecords = records.size();
}
void MParted::MParted_Core::scanDevicePartitions(MParted::Device &device) {
    device.partitions.clear();

    // Initialise
    PedPartition *pedPartition = NULL;
    MParted::Partition *extendedPartition = NULL;

    while ((pedPartition = ped_disk_next_partition(pedDisk, pedPartition))) {
        //if there's no end, there's no partition ;)
        if (pedPartition->geom.end <= -1)
            continue;

        MParted::Partition partition;
        partition.devicePath = device.path;
        partition.sector_size = device.sector_size;
        partition.busy = ped_partition_is_busy(pedPartition);
        partition.partitionNumber = pedPartition->num;
        partition.sector_start = pedPartition->geom.start;
        partition.sector_end = pedPartition->geom.end;

        // Get partition path
        partition.path = Utils::charToStringFree(ped_partition_get_path(pedPartition)); // we have to free the result of ped_partition_get_path()
        if (partition.path.isEmpty())
            partition.path = "Partition path not found";


        switch (pedPartition->type) {
            case PED_PARTITION_LOGICAL:
                partition.insideExtended = true;

            case PED_PARTITION_NORMAL:
                partition.type = pedPartition->type == 0 ?	MParted::TYPE_PRIMARY : MParted::TYPE_LOGICAL;
                partition.filesystem = getFilesystem(pedPartition);

                // Find filesystem class and set used sectors, label and uuid
                for (int i = 0; i < filesystems.size(); i++) {
                    MParted::Filesystem *fs = filesystems[i];

                    if (fs->getFilesystemType() != partition.filesystem)
                        continue;

                    fs->setUsedSectors(partition);
                    fs->readLabel(partition);
                    fs->readUUID(partition);
                    break;
                }

                break ;
            case PED_PARTITION_EXTENDED:
                partition.type = MParted::TYPE_EXTENDED;
                partition.filesystem = MParted::FS_EXTENDED;

                break ;
            default:
                continue;
        }

        // Add partition to list
        if (partition.type == MParted::TYPE_LOGICAL && extendedPartition != NULL)
            extendedPartition->logicals.append(partition);
        else
            device.partitions.append(partition);

        // Save pointer of extended partition, if it is one
        if (partition.type == MParted::TYPE_EXTENDED)
            extendedPartition = &device.partitions.last();
    }

    // Update unallocated space
    UnallocatedUtils::updateUnallocated(device);
}