Beispiel #1
0
// tearDown
void
BroadcastTester::tearDown()
{
	BMimeType(appType1).Delete();
	BMimeType(appType2).Delete();
	BMimeType(appType3).Delete();
	BMimeType(appType4).Delete();
	delete fApplication;
	system((string("rm -rf ") + testDir).c_str());
}
Beispiel #2
0
// create_app
static
entry_ref
create_app(const char *filename, const char *signature,
		   bool install = false, bool makeExecutable = true,
		   uint32 appFlags = B_SINGLE_LAUNCH)
{
	BString testApp;
	CHK(find_test_app("RosterBroadcastTestApp1", &testApp) == B_OK);
	system((string("cp ") + testApp.String() + " " + filename).c_str());
	if (makeExecutable)
		system((string("chmod a+x ") + filename).c_str());
	BFile file;
	CHK(file.SetTo(filename, B_READ_WRITE) == B_OK);
	BAppFileInfo appFileInfo;
	CHK(appFileInfo.SetTo(&file) == B_OK);
	if (signature)
		CHK(appFileInfo.SetSignature(signature) == B_OK);
	CHK(appFileInfo.SetAppFlags(appFlags) == B_OK);
	if (install && signature)
		CHK(BMimeType(signature).Install() == B_OK);
	// We write the signature into a separate attribute, just in case we
	// decide to also test files without BEOS:APP_SIG attribute.
	BString signatureString(signature);
	file.WriteAttrString("signature", &signatureString);
	return ref_for_path(filename);
}
Beispiel #3
0
BBitmap* CFtpDialog::GetIcon(const char *mimeType, const char *tryExtension)
{
	map<string,string>::iterator iterExt;
	map<string,BBitmap*>::iterator iterBmp;

	if (*tryExtension != '\0' && (iterExt = fExtMime.find(tryExtension)) != fExtMime.end())
		return GetIcon(iterExt->second.c_str());

	if ((iterBmp = fIcons.find(mimeType)) == fIcons.end())
	{
		BBitmap* bm = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
		if (BMimeType(mimeType).GetIcon(bm, B_MINI_ICON) != B_OK)
			BMimeType("application/octet-stream").GetIcon(bm, B_MINI_ICON);
		fIcons[mimeType] = bm;
		return bm;
	}
	else
		return iterBmp->second;
} // CFtpDialog::GetIcon
Beispiel #4
0
void Fenster::Help() {
	app_info	myAppInfo;
	be_app->GetAppInfo(&myAppInfo);
	
	BPath	HelpFilePath;
	BPath(&myAppInfo.ref).GetParent(&HelpFilePath);
	HelpFilePath.Append(HELP_FILE);
	
	entry_ref	ref;
	char		Signatur[B_MIME_TYPE_LENGTH];

	BMimeType("text/html").GetPreferredApp(Signatur);
	BMimeType(Signatur).GetAppHint(&ref);
	
	if ( (BPath(&ref).Path()==NULL) || (!BEntry(HelpFilePath.Path()).Exists()) ) {
		BAlert*	myAlert = new BAlert(NULL, MESSAGE_NOHELP, STR_OK);
		myAlert->Go(); return;
	}
	
	BString		Befehl(BPath(&ref).Path());
	Befehl.Append(" file://").Append(HelpFilePath.Path()).Append(" &");

	system(Befehl.String());
};
void
Renamer_Extension::RenameList(BList* FileList)
{
	Renamer::RenameList(FileList);

	const bool replaceold = bool(fReplaceOldCheckBox->Value());
	const int32	upperlower = fLowerCase->Value() == B_CONTROL_ON;

	FileListItem* ListItem;
	BMessage msg;
	const char* ExtensionString;
	BString Extension, NewName;
	int	OldExtStart;
	
	for (int32 i = 0; i < fNumberOfItems; i++) {
		ListItem = (FileListItem*)FileList->ItemAt(i);

		if (BMimeType((char*)&ListItem->fMimeType).GetFileExtensions(&msg)
				== B_OK) {
			for (int32 j = 0; (msg.FindString("extensions", j, &ExtensionString)
					== B_OK); j++) {
				if (strlen(ExtensionString) < MAX_EXTENSION_LENGTH) {
					Extension = ExtensionString; Extension.Prepend(".");
					if (upperlower)
						Extension.ToLower();
					else
						Extension.ToUpper();

					NewName = ListItem->fName;
					if ((replaceold)
							&& ((OldExtStart = NewName.FindLast(".")) > 0)) {
						ListItem->SetNewName(NewName
							.Truncate(OldExtStart).Append(Extension));
					} else
						ListItem->SetNewName(NewName.Append(Extension));
					break;
				}
			}
		}
	}
};