コード例 #1
0
void BOMFilesBTree::listDirectory(uint32_t parentID, std::map<uint32_t, BOMPathElement>& contents)
{
	std::vector<BOMBTreeNode> leaves;
	BOMPathKey key;
	
	contents.clear();
	
	key.parentItemID = htobe32(parentID);
	key.name[0] = 0;
	
	leaves = findLeafNodes(&key, BOMFilesBTree::KeyComparator(keyComparator));
	
	for (BOMBTreeNode& leaf : leaves)
	{
		BOMBTreeNode::RecordIterator<BOMPathKey> it;
		
		it = std::lower_bound(leaf.begin<BOMPathKey>(), leaf.end<BOMPathKey>(), key.parentItemID,
			[](const BOMPathKey* k, uint32_t v) {
				return be(k->parentItemID) < be(v);
		});
		
		while (it != leaf.end<BOMPathKey>())
		{
			BOMPathKey* lkey;
			BOMLeafDescriptor* ldesc;
			BOMPathRecord* ldata;
			
			lkey = *it;
			
			if (lkey->parentItemID != key.parentItemID)
				break;
			
			ldesc = leaf.getRecordData<BOMLeafDescriptor>(it.index());
			ldata = m_store->getBlockData<BOMPathRecord>(be(ldesc->recordID));
			
			// TODO: size64
			contents[be(ldesc->itemID)] = BOMPathElement(lkey->name, ldata, 0);
			++it;
		}
	}
}
コード例 #2
0
std::map<std::string, std::vector<uint8_t>> HFSAttributeBTree::getattr(HFSCatalogNodeID cnid)
{
	HFSPlusAttributeKey key;
	std::vector<HFSBTreeNode> leaves;
	std::map<std::string, std::vector<uint8_t>> rv;

	memset(&key, 0, sizeof(key));
	key.fileID = htobe32(cnid);

	leaves = findLeafNodes((Key*) &key, cnidComparator);
	
	for (const HFSBTreeNode& leaf : leaves)
	{
		for (int i = 0; i < leaf.recordCount(); i++)
		{
			HFSPlusAttributeKey* recordKey = leaf.getRecordKey<HFSPlusAttributeKey>(i);
			HFSPlusAttributeDataInline* data;
			std::vector<uint8_t> vecData;
			std::string name;

			if (be(recordKey->fileID) != cnid)
				continue;

			data = leaf.getRecordData<HFSPlusAttributeDataInline>(i);

			// process data
			if (be(data->recordType) != kHFSPlusAttrInlineData)
				continue;
			
			vecData = std::vector<uint8_t>(data->attrData, &data->attrData[be(data->attrSize)]);
			name = UnicharToString(be(recordKey->attrNameLength), recordKey->attrName);
			
			rv[name] = vecData;
		}
	}
	
	return rv;
}