当前位置: 首页>>代码示例>>C++>>正文


C++ BMimeType::SetFileExtensions方法代码示例

本文整理汇总了C++中BMimeType::SetFileExtensions方法的典型用法代码示例。如果您正苦于以下问题:C++ BMimeType::SetFileExtensions方法的具体用法?C++ BMimeType::SetFileExtensions怎么用?C++ BMimeType::SetFileExtensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BMimeType的用法示例。


在下文中一共展示了BMimeType::SetFileExtensions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

void
InitFileTypes(void)
{
	BMimeType mime;
	BString string;
	BMessage msg,ext;
	
	BBitmap	large_icon(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_COLOR_8_BIT);
	memcpy(large_icon.Bits(),kProjectLargeIconBits,1024);
	BBitmap	mini_icon(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_COLOR_8_BIT);
	memcpy(mini_icon.Bits(),kProjectSmallIconBits,256);
	
	mime.SetType(PROJECT_MIME_TYPE);
	mime.SetShortDescription(TR("Paladin Project"));
	mime.SetLongDescription(TR("File to build a program with Paladin"));
	mime.SetIcon(&large_icon, B_LARGE_ICON);
	mime.SetIcon(&mini_icon, B_MINI_ICON);
	
	#ifdef __HAIKU__
	mime.SetIcon(kProjectVectorIconBits, sizeof(kProjectVectorIconBits));
	#endif
	
	mime.SetSnifferRule("0.50  [0:32]( -i \"NAME=\" | \"TARGETNAME=\" | "
						"\"PLATFORM=\" | \"GROUP=\" | \"SOURCEFILE=\")");
	mime.SetPreferredApp(APP_SIGNATURE);
	mime.Install();
	
	ext.AddString("extensions","pld");
	mime.SetFileExtensions(&ext);
}
开发者ID:tgkokk,项目名称:Paladin,代码行数:30,代码来源:FileUtils.cpp

示例2:

//! newExtensionsList contains all the entries (char*) which are to be added.
status_t
merge_extensions(BMimeType& type, const BList& newExtensionsList,
	const char* removeExtension)
{
	BMessage extensions;
	status_t status = type.GetFileExtensions(&extensions);
	if (status < B_OK)
		return status;

	// replace the entry, and remove any equivalent entries
	BList mergedList;
	mergedList.AddList(&newExtensionsList);
	int32 originalCount = mergedList.CountItems();

	const char* extension;
	for (int32 i = 0; extensions.FindString("extensions", i,
			&extension) == B_OK; i++) {

		for (int32 j = originalCount; j-- > 0;) {
			if (!strcmp((const char*)mergedList.ItemAt(j), extension)) {
				// Do not add this old item again, since it's already
				// there.
				mergedList.RemoveItem(j);
				originalCount--;
			}
		}

		// The item will be added behind "originalCount", so we cannot
		// remove it accidentally in the next iterations, it's is added
		// for good.
		if (removeExtension == NULL || strcmp(removeExtension, extension))
			mergedList.AddItem((void *)extension);
	}

	mergedList.SortItems(compare_extensions);

	// Copy them to a new message (their memory is still part of the
	// original BMessage)
	BMessage newExtensions;
	for (int32 i = 0; i < mergedList.CountItems(); i++) {
		newExtensions.AddString("extensions",
			(const char*)mergedList.ItemAt(i));
	}

	return type.SetFileExtensions(&newExtensions);
}
开发者ID:mmanley,项目名称:Antares,代码行数:47,代码来源:ExtensionWindow.cpp


注:本文中的BMimeType::SetFileExtensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。