本文整理汇总了C++中BTranslatorRoster::IsTranslator方法的典型用法代码示例。如果您正苦于以下问题:C++ BTranslatorRoster::IsTranslator方法的具体用法?C++ BTranslatorRoster::IsTranslator怎么用?C++ BTranslatorRoster::IsTranslator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTranslatorRoster
的用法示例。
在下文中一共展示了BTranslatorRoster::IsTranslator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
void
DataTranslationsApplication::RefsReceived(BMessage* message)
{
BTranslatorRoster* roster = BTranslatorRoster::Default();
BPath path;
status_t status = find_directory(B_USER_ADDONS_DIRECTORY, &path, true);
if (status != B_OK) {
_InstallError("translator", status);
return;
}
BDirectory target;
status = target.SetTo(path.Path());
if (status == B_OK) {
if (!target.Contains("Translators"))
status = target.CreateDirectory("Translators", &target);
else
status = target.SetTo(&target, "Translators");
}
if (status != B_OK) {
_InstallError("translator", status);
return;
}
int32 i = 0;
entry_ref ref;
while (message->FindRef("refs", i++, &ref) == B_OK) {
if (!roster->IsTranslator(&ref)) {
_NoTranslatorError(ref.name);
continue;
}
BEntry entry(&ref, true);
status = entry.InitCheck();
if (status != B_OK) {
_InstallError(ref.name, status);
continue;
}
if (target.Contains(ref.name)) {
BString string(
B_TRANSLATE("An item named '%name' already exists in the "
"Translators folder! Shall the existing translator be "
"overwritten?"));
string.ReplaceAll("%name", ref.name);
BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
string.String(), B_TRANSLATE("Cancel"),
B_TRANSLATE("Overwrite"));
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() != 1)
continue;
// the original file will be replaced
}
// find out whether we need to copy it or not
status = _Install(target, entry);
if (status == B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
B_TRANSLATE("The new translator has been installed "
"successfully."), B_TRANSLATE("OK"));
alert->Go(NULL);
} else
_InstallError(ref.name, status);
}
}