本文整理汇总了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);
}
示例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);
}