Example #1
0
void
BNavMenu::BuildVolumeMenu()
{
	BVolumeRoster roster;
	BVolume	volume;

	roster.Rewind();
	while (roster.GetNextVolume(&volume) == B_OK) {
		
		if (!volume.IsPersistent())
			continue;
		
		BDirectory startDir;
		if (volume.GetRootDirectory(&startDir) == B_OK) {
			BEntry entry;
			startDir.GetEntry(&entry);

			Model *model = new Model(&entry);
			if (model->InitCheck() != B_OK) {
				delete model;
				continue;
			}
			
			BNavMenu *menu = new BNavMenu(model->Name(), fMessage.what,
				fMessenger, fParentWindow, fTypesList);

			menu->SetNavDir(model->EntryRef());

			ASSERT(menu->Name());

			ModelMenuItem *item = new ModelMenuItem(model, menu);
			BMessage *message = new BMessage(fMessage);

			message->AddRef("refs", model->EntryRef());

			item->SetMessage(message);
			fItemList->AddItem(item);
			ASSERT(item->Label());
			
		}
	}
}
bool
BTrashWatcher::CheckTrashDirs()
{
	BVolumeRoster volRoster;
	volRoster.Rewind();
	BVolume	volume;
	while (volRoster.GetNextVolume(&volume) == B_OK) {
		if (volume.IsReadOnly() || !volume.IsPersistent())
			continue;

		BDirectory trashDir;
		FSGetTrashDir(&trashDir, volume.Device());
		trashDir.Rewind();
		BEntry entry;
		if (trashDir.GetNextEntry(&entry) == B_OK)
			return true;
	}

	return false;
}
Example #3
0
status_t
BPrinter::SetTo(const BDirectory& directory)
{
	StopWatching();

	BEntry entry;
	directory.GetEntry(&entry);
	entry.GetRef(&fPrinterEntryRef);

	return InitCheck();
}
status_t HModuleRoster::LoadModules( BPath *moduleDirectory )
{
	status_t		status;
	BDirectory		dir;
	
	if( (status = dir.SetTo( moduleDirectory->Path() )) == B_OK )
	{
		BEntry		entry;
		BPath		modulePath;
		
		while( dir.GetNextEntry( &entry, true ) != B_ENTRY_NOT_FOUND )
		{
			entry.GetPath( &modulePath );
			LoadModule( &modulePath );
		}
	}
	else
		return status;
	return B_OK;
}
void
delete_directory_path(char *path,bool recur)
{
	BDirectory 	*dir;
	BPath		*pat,pt;
	BEntry		*ent;

	if ((pat = create_path(path)))
	{
		if	((dir = create_mydir((char *)pat->Path())))
		{
			if	(dir->Rewind() == B_OK)
			{
				if	((ent = new BEntry()))
				{
					while (dir->GetNextEntry(ent,false) == B_NO_ERROR)
					{
						if (ent->GetPath(&pt) == B_NO_ERROR)
						{
							if (recur)
							{
								if	(ent->IsDirectory())
								{
									delete_directory_path((char *)pt.Path(),recur);
								}
							}
						}

						ent->Remove();
					}

					delete ent;
				}
			}

			delete dir;
		}

		delete pat;
	}
}
Example #6
0
void
TBarWindow::MenusBeginning()
{
	BPath path;
	entry_ref ref;

	find_directory (B_USER_DESKBAR_DIRECTORY, &path);
	get_ref_for_path(path.Path(), &ref);

	BEntry entry(&ref, true);
	if (entry.InitCheck() == B_OK && entry.IsDirectory()) {
		//	need the entry_ref to the actual item
		entry.GetRef(&ref);
		//	set the nav directory to the be folder
		sBeMenu->SetNavDir(&ref);
	} else if (!entry.Exists()) {
		//	the Be folder does not exist
		//	create one now
		BDirectory dir;
		if (entry.GetParent(&dir) == B_OK) {
			BDirectory bedir;
			dir.CreateDirectory("be", &bedir);
			if (bedir.GetEntry(&entry) == B_OK
				&& entry.GetRef(&ref) == B_OK)
				sBeMenu->SetNavDir(&ref);
		}
	} else {
		//	this really should never happen
		TRESPASS();
		return;
	}

	sBeMenu->NeedsToRebuild();
	sBeMenu->ResetTargets();

	fBarView->SetEventMask(0);
		// This works around a BeOS bug - the menu is quit with every
		// B_MOUSE_DOWN the window receives...

	BWindow::MenusBeginning();
}
Example #7
0
void
TTracker::InstallTemporaryBackgroundImages()
{
	// make the large Haiku Logo the default background

	BPath path;
	status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path);
	if (status < B_OK) {
		// TODO: this error shouldn't be shown to the regular user
		BString errorMessage(B_TRANSLATE("At %func \nfind_directory() "
			"failed. \nReason: %error"));
		errorMessage.ReplaceFirst("%func", __PRETTY_FUNCTION__);
		errorMessage.ReplaceFirst("%error", strerror(status));
		BAlert* alert = new BAlert("AlertError", errorMessage.String(),
			B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
		return;
	}
	path.Append("artwork");

	BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png");

	BDirectory dir;
	if (FSGetBootDeskDir(&dir) == B_OK) {
		// install a default background if there is no background defined yet
		attr_info info;
		if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) {
			BScreen screen(B_MAIN_SCREEN_ID);
			BPoint logoPos;
			logoPos.x
				= floorf((screen.Frame().Width() - 605) * (sqrtf(5) - 1) / 2);
			logoPos.y = floorf((screen.Frame().Height() - 190) * 0.9);
			BMessage message;
			AddTemporaryBackgroundImages(&message,
				(BString(path.Path()) << defaultBackgroundImage).String(),
				BackgroundImage::kAtOffset, logoPos, 0xffffffff, false);
			::InstallTemporaryBackgroundImages(&dir, &message);
		}
	}
}
Example #8
0
void
BootPromptWindow::_PopulateKeymaps()
{
	// Get the name of the current keymap, so we can mark the correct entry
	// in the list view.
	BString currentName;
	entry_ref currentRef;
	if (_GetCurrentKeymapRef(currentRef) == B_OK) {
		BNode node(&currentRef);
		node.ReadAttrString("keymap:name", &currentName);
	}

	// TODO: common keymaps!
	BPath path;
	if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK
		|| path.Append("Keymaps") != B_OK) {
		return;
	}

	// US-International is the default keymap, if we could not found a
	// matching one
	BString usInternational("US-International");

	// Populate the menu
	BDirectory directory;
	if (directory.SetTo(path.Path()) == B_OK) {
		entry_ref ref;
		while (directory.GetNextRef(&ref) == B_OK) {
			BMessage* message = new BMessage(MSG_KEYMAP_SELECTED);
			message->AddRef("ref", &ref);
			BMenuItem* item = new BMenuItem(ref.name, message);
			fKeymapsMenuField->Menu()->AddItem(item);

			if (currentName == ref.name)
				item->SetMarked(true);

			if (usInternational == ref.name)
				fDefaultKeymapItem = item;
		}
	}
}
Example #9
0
status_t
ThemeManager::LoadTheme(const char *path, BMessage **to)
{
	status_t err;
	BDirectory dir;
	BFile f;
	BMessage *theme;
#ifdef DEBUG_TM
	PRINT(("ThemeManager::%s(%s)\n", __FUNCTION__, path));
#endif
	
	err = dir.SetTo(path);
	if (err)
		fprintf(stderr, "ThemeManager:: BDirectory::SetTo 0x%08lx\n", err);
	if (err) { /* not a dir, check for a zip */
		// TODO
		// unzip + recursive call
		return err;
	}
	err = f.SetTo(&dir, Z_THEME_FILE_NAME, B_READ_ONLY);
	if (err)
		fprintf(stderr, "ThemeManager:: BFile::SetTo 0x%08lx\n", err);
	if (err)
		return err;
	err = ParseMessageFromStream(&theme, f);
	if (err)
		fprintf(stderr, "ThemeManager:: ParseMessageFromStream 0x%08lx\n", err);
	if (err)
		return err;
	err = theme->RemoveName(Z_THEME_LOCATION);
	err = theme->AddString(Z_THEME_LOCATION, path);
	//theme->PrintToStream();
	err = AddTheme(theme);
	if (err)
		fprintf(stderr, "ThemeManager:: AddTheme 0x%08lx\n", err);
	if (err)
		delete theme;
	if (!err && to)
		*to = theme;
	return err;
}
Example #10
0
void
MailProtocolThread::TriggerFileMove(const entry_ref& ref, BDirectory& dir)
{
    BMessage message(kMsgMoveFile);
    message.AddRef("file", &ref);
    BEntry entry;
    dir.GetEntry(&entry);
    entry_ref dirRef;
    entry.GetRef(&dirRef);
    message.AddRef("directory", &dirRef);
    PostMessage(&message);
}
Example #11
0
void
AddOnManager::_GetReaders(const BPath& path, entry_ref* outRefs,
	int32* outCount, int32 maxCount)
{
	node_ref nref;
	BDirectory directory;
	if (directory.SetTo(path.Path()) != B_OK
		|| directory.GetNodeRef(&nref) != B_OK) {
		return;
	}

	reader_info* info;
	for (fReaderList.Rewind(); fReaderList.GetNext(&info)
		&& *outCount < maxCount;) {
		if (info->ref.directory != nref.node)
			continue;

		outRefs[*outCount] = info->ref;
		(*outCount)++;
	}
}
/*	isProject
* checks if an selected folder is a lava project folder.
*/
bool
ProjectTypeSelector::isProject()
{
	BNode objNode;
	BString *Project = (BString*)FileList->FirstItem();
	objNode.SetTo(Project->String());
	
	char buffer[500];
	memset(buffer, 0, sizeof(buffer));

	if(objNode.ReadAttr("LAVA:Type", B_STRING_TYPE, 0, buffer, sizeof(buffer)) == B_ENTRY_NOT_FOUND)
		return false;
	else {
		BDirectory objDir;
		objDir.SetTo(Project->String());
		if(objDir.InitCheck() != B_OK)
			return false;
		else
			return true;
	}
}
Example #13
0
// OpenModuleList
module_name_list *
ModuleManager::OpenModuleList(const char *prefix, const char *suffix)
{
	module_name_list *list = NULL;
	if (prefix) {
		list = new module_name_list;
		_FindBuiltInModules(prefix, suffix, list);

		for (int32 i = 0; gModuleDirs[i]; i++) {
			BPath path;
			BDirectory dir;
			if (path.SetTo(gModuleDirs[i], prefix) == B_OK
				&& dir.SetTo(path.Path()) == B_OK) {
				_FindModules(dir, gModuleDirs[i], suffix, list);
			}
		}

		list->it = list->names.begin();
	}
	return list;
}
Example #14
0
void
DialUpView::LoadInterfaces()
{
	fInterfaceMenu->AddSeparatorItem();
	fInterfaceMenu->AddItem(new BMenuItem(kLabelCreateNewInterface,
		new BMessage(kMsgCreateNew)));
	fDeleterItem = new BMenuItem(kLabelDeleteCurrent,
		new BMessage(kMsgDeleteCurrent));
	fInterfaceMenu->AddItem(fDeleterItem);
	
	BDirectory settingsDirectory;
	BEntry entry;
	BPath path;
	GetPPPDirectories(&settingsDirectory, NULL);
	while(settingsDirectory.GetNextEntry(&entry) == B_OK) {
		if(entry.IsFile()) {
			entry.GetPath(&path);
			AddInterface(path.Leaf(), true);
		}
	}
}
Example #15
0
void
TMailApp::_CheckForSpamFilterExistence()
{
	// Looks at the filter settings to see if the user is using a spam filter.
	// If there is one there, set fShowSpamGUI to TRUE, otherwise to FALSE.

	int32 addonNameIndex;
	const char *addonNamePntr;
	BDirectory inChainDir;
	BPath path;
	BEntry settingsEntry;
	BFile settingsFile;
	BMessage settingsMessage;

	fShowSpamGUI = false;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
		return;
	// TODO use new settings
	path.Append("Mail/chains/inbound");
	if (inChainDir.SetTo(path.Path()) != B_OK)
		return;

	while (inChainDir.GetNextEntry (&settingsEntry, true /* traverse */) == B_OK) {
		if (!settingsEntry.IsFile())
			continue;
		if (settingsFile.SetTo (&settingsEntry, B_READ_ONLY) != B_OK)
			continue;
		if (settingsMessage.Unflatten (&settingsFile) != B_OK)
			continue;
		for (addonNameIndex = 0; B_OK == settingsMessage.FindString (
			"filter_addons", addonNameIndex, &addonNamePntr);
			addonNameIndex++) {
			if (strstr (addonNamePntr, "Spam Filter") != NULL) {
				fShowSpamGUI = true; // Found it!
				return;
			}
		}
	}
}
Example #16
0
void SysAddDiskPrefs(void)
{
	// Let BeOS scan for HFS drives
	D(bug("Looking for Mac volumes...\n"));
	system("mountvolume -allhfs");

	// Add all HFS volumes
	int32 i = 0;
	dev_t d;
	fs_info info;
	while ((d = next_dev(&i)) >= 0) {
		fs_stat_dev(d, &info);
		status_t err = -1;
		BPath mount;
		if (!strcmp(info.fsh_name, "hfs")) {
			BDirectory dir;
			BEntry entry;
			node_ref node;
			node.device = info.dev;
			node.node = info.root;
			err = dir.SetTo(&node);
			if (!err)
				err = dir.GetEntry(&entry);
			if (!err)
				err = entry.GetPath(&mount);
		}
		if (!err)
			err = unmount(mount.Path());
		if (!err) {
			char dev_name[B_FILE_NAME_LENGTH];
			if (info.flags & B_FS_IS_READONLY) {
				dev_name[0] = '*';
				dev_name[1] = 0;
			} else
				dev_name[0] = 0;
			strcat(dev_name, info.device_name);
			PrefsAddString("disk", dev_name);
		}
	}
}
Example #17
0
bool
DialUpView::SaveSettingsToFile()
{
	bool settingsChanged, profileChanged;
	IsModified(&settingsChanged, &profileChanged);
	if(!settingsChanged && !profileChanged)
		return true;
	
	BMessage settings, profile;
	if(!SaveSettings(&settings, &profile, false))
		return false;
	
	BDirectory settingsDirectory;
	BDirectory profileDirectory;
	GetPPPDirectories(&settingsDirectory, &profileDirectory);
	if(settingsDirectory.InitCheck() != B_OK || profileDirectory.InitCheck() != B_OK)
		return false;
	
	BFile file;
	if(settingsChanged) {
		settingsDirectory.CreateFile(fCurrentItem->Label(), &file);
		WriteMessageDriverSettings(file, settings);
	}
	
	if(profileChanged) {
		profileDirectory.CreateFile(fCurrentItem->Label(), &file);
		WriteMessageDriverSettings(file, profile);
	}
	
	return true;
}
void
VirtualKeyboardWindow::_LoadLayoutMenu(BMenu* menu, BDirectory directory)
{
	entry_ref ref;

	while (directory.GetNextRef(&ref) == B_OK) {
		if (menu->FindItem(ref.name) != NULL)
			continue;

		BDirectory subdirectory;
		subdirectory.SetTo(&ref);
		if (subdirectory.InitCheck() == B_OK) {
			BMenu* submenu = new BMenu(ref.name);
			_LoadLayoutMenu(submenu, subdirectory);
			menu->AddItem(submenu);
		} else {
			//BMessage* message = new BMessage(kChangeKeyboardLayout);
			//message->AddRed("ref",&ref);
			menu->AddItem(new BMenuItem(ref.name, NULL));
		}
	}
}
Example #19
0
int32_t
PDirectoryCreateDirectory(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PDirectory *parent = static_cast<PDirectory*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BDirectory *backend = (BDirectory*)parent->GetBackend();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	
	BString path;
	if (args->FindString("path", &path) != B_OK)
		return B_ERROR;
	
	BDirectory newDir;
	status_t status = backend->CreateDirectory(path.String(), &newDir);
	
	outArgs->MakeEmpty();
	
	if (status == B_OK)
	{
		BEntry entry;
		status = newDir.GetEntry(&entry);
		if (status == B_OK)
		{
			BPath dirPath;
			status = entry.GetPath(&dirPath);
			outArgs->AddString("path", dirPath.Path());
		}
	}
	
	outArgs->AddInt32("status", status);
	
	return B_OK;
}
void
VirtualKeyboardWindow::_LoadLayouts(BMenu* menu)
{
	directory_which dataDirectories[] = {
		B_USER_NONPACKAGED_DATA_DIRECTORY,
		B_USER_DATA_DIRECTORY,
		B_SYSTEM_NONPACKAGED_DIRECTORY,
		B_SYSTEM_DATA_DIRECTORY,
	};

	for (uint i = 0; i < sizeof(dataDirectories)/sizeof(directory_which); i++) {
		BPath path;
		if (find_directory(dataDirectories[i], &path) != B_OK)
			continue;

		path.Append("KeyboardLayouts");

		BDirectory directory;
		if (directory.SetTo(path.Path()) == B_OK)
			_LoadLayoutMenu(menu, directory);
	}
}
Example #21
0
void
KeymapWindow::_AddKeyboardLayouts(BMenu* menu)
{
    directory_which dataDirectories[] = {
        B_USER_DATA_DIRECTORY,
        B_COMMON_DATA_DIRECTORY,
        B_BEOS_DATA_DIRECTORY
    };

    for (uint32 i = 0;
            i < sizeof(dataDirectories) / sizeof(dataDirectories[0]); i++) {
        BPath path;
        if (find_directory(dataDirectories[i], &path) != B_OK)
            continue;

        path.Append("KeyboardLayouts");

        BDirectory directory;
        if (directory.SetTo(path.Path()) == B_OK)
            _AddKeyboardLayoutMenu(menu, directory);
    }
}
void
PersonWindow::SaveAs(int32 format)
{
	if (format == 0)
		format = B_PERSON_FORMAT;

	char name[B_FILE_NAME_LENGTH];
	_GetDefaultFileName(name);

	if (fPanel == NULL) {
		BPath path;
		BMessenger target(this);
		BMessage msg(B_SAVE_REQUESTED);
		msg.AddInt32("format", format);
		fPanel = new BFilePanel(B_SAVE_PANEL, &target, NULL, 0, true, &msg);
		

		find_directory(B_USER_DIRECTORY, &path, true);

		BDirectory dir;
		dir.SetTo(path.Path());

		BEntry entry;
		if (dir.FindEntry("people", &entry) == B_OK
			|| (dir.CreateDirectory("people", &dir) == B_OK
					&& dir.GetEntry(&entry) == B_OK)) {
			fPanel->SetPanelDirectory(&entry);
		}
	}

	if (fPanel->Window()->Lock()) {
		fPanel->SetSaveText(name);
		if (fPanel->Window()->IsHidden())
			fPanel->Window()->Show();
		else
			fPanel->Window()->Activate();
		fPanel->Window()->Unlock();
	}
}
Example #23
0
void
FileTypes::ArgvReceived(int32 argc, char** argv)
{
    if (argc == 3 && strcmp(argv[1], "-type") == 0) {
        fArgvType = argv[2];
        return;
    }

    BMessage* message = CurrentMessage();

    BDirectory currentDirectory;
    if (message != NULL)
        currentDirectory.SetTo(message->FindString("cwd"));

    BMessage refs;

    for (int i = 1 ; i < argc ; i++) {
        BPath path;
        if (argv[i][0] == '/')
            path.SetTo(argv[i]);
        else
            path.SetTo(&currentDirectory, argv[i]);

        status_t status;
        entry_ref ref;
        BEntry entry;

        if ((status = entry.SetTo(path.Path(), false)) != B_OK
                || (status = entry.GetRef(&ref)) != B_OK) {
            fprintf(stderr, "Could not open file \"%s\": %s\n",
                    path.Path(), strerror(status));
            continue;
        }

        refs.AddRef("refs", &ref);
    }

    RefsReceived(&refs);
}
Example #24
0
void
TTracker::InstallTemporaryBackgroundImages()
{
	// make the large Haiku Logo the default background

	BPath path;
	status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path);
	if (status < B_OK) {
		BString errorMessage;
		errorMessage << "At " << __PRETTY_FUNCTION__ << "\n";
		errorMessage << "find_directory() failed. \nReason: ";
		errorMessage << strerror(status);
		(new BAlert("AlertError", errorMessage.String(), "OK", NULL, NULL,
			B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
		return;
	}
	path.Append("artwork");

	BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png");

	BDirectory dir;
	if (FSGetBootDeskDir(&dir) == B_OK) {
		// install a default background if there is no background defined yet
		attr_info info;
		if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) {
			BScreen screen(B_MAIN_SCREEN_ID);
			BPoint logoPos;
			logoPos.x
				= floorf((screen.Frame().Width() - 605) * (sqrtf(5) - 1) / 2);
			logoPos.y = floorf((screen.Frame().Height() - 190) * 0.9);
			BMessage message;
			AddTemporaryBackgroundImages(&message,
				(BString(path.Path()) << defaultBackgroundImage).String(),
				BackgroundImage::kAtOffset, logoPos, 0xffffffff, false);
			::InstallTemporaryBackgroundImages(&dir, &message);
		}
	}
}
//---------------------------------------------------------------------
//	HandleDirectory
//---------------------------------------------------------------------
//	iterate through the directory and pass the resulting
//	refs and attempt to add the resulting file
//
status_t TQueueDialog::HandleDirectory(entry_ref &ref, struct stat &st, BDirectory &dir) 
{
	struct stat s; 
	BEntry entry; 
	
	dir.Rewind();
	while (true)
	{
		if (dir.GetNextEntry(&entry) == B_OK)
		{
			entry.GetStat(&s);
			
			entry_ref eRef;
			entry.GetRef(&eRef);
//			HandleFile(eRef, s);
			EvaluateRef(eRef);
		} else
			break;
	}
		

	return B_ERROR;
}
Example #26
0
status_t
PDirectory::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BDirectory *backend = (BDirectory*)fBackend;
	if (str.ICompare("IsRoot") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsRootDirectory());
	else if (str.ICompare("EntryCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountEntries());
	else
	{
		return PNode::GetProperty(name, value, index);
	}

	return prop->GetValue(value);
}
Example #27
0
void
Model::ResetIconFrom()
{
	BModelOpener opener(this);

	if (InitCheck() != B_OK)
		return;

	// mirror the logic from FinishSettingUpType
	if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode
			|| fBaseType == kTrashNode || fBaseType == kDesktopNode)
		&& !CheckNodeIconHint(fNode)) {
		BDirectory* directory = dynamic_cast<BDirectory*>(fNode);
		if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) {
			fIconFrom = kTrackerSupplied;
			return;
		} else if (directory != NULL && directory->IsRootDirectory()) {
			fIconFrom = kVolume;
			return;
		}
	}
	fIconFrom = kUnknownSource;
}
Example #28
0
void
KeymapWindow::_FillSystemMaps()
{
	BListItem *item;
	while ((item = fSystemListView->RemoveItem(static_cast<int32>(0))))
		delete item;

	// TODO: common keymaps!
	BPath path;
	if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK)
		return;

	path.Append("Keymaps");

	BDirectory directory;
	entry_ref ref;

	if (directory.SetTo(path.Path()) == B_OK) {
		while (directory.GetNextRef(&ref) == B_OK) {
			fSystemListView->AddItem(new KeymapListItem(ref));
		}
	}
}
BFile*
MilkySettingsApplication::_OpenSettingsFile(uint32 openMode)
{
    BPath path;
    find_directory(B_USER_SETTINGS_DIRECTORY, &path);
    path.Append("MilkyTracker");

    BEntry dirEntry(path.Path());
    if (!dirEntry.Exists()) {
        // MilkyTracker settings dir doesn't exist, create it
        BDirectory temp;
        temp.CreateDirectory(path.Path(), NULL);
    }

    path.Append("platform_settings");
    BFile* file = new BFile(path.Path(), openMode);

    if (file->InitCheck() != B_OK) {
        delete file;
        return NULL;
    }

    return file;
}
Example #30
0
void
ServerApp::_LaunchAddOnServer()
{
	// Try to launch media_addon_server by mime signature.
	// If it fails (for example on the Live CD, where the executable
	// hasn't yet been mimesetted), try from this application's
	// directory
	status_t err = be_roster->Launch(B_MEDIA_ADDON_SERVER_SIGNATURE);
	if (err == B_OK)
		return;

	app_info info;
	BEntry entry;
	BDirectory dir;
	entry_ref ref;

	err = GetAppInfo(&info);
	err |= entry.SetTo(&info.ref);
	err |= entry.GetParent(&entry);
	err |= dir.SetTo(&entry);
	err |= entry.SetTo(&dir, "media_addon_server");
	err |= entry.GetRef(&ref);

	if (err == B_OK)
		be_roster->Launch(&ref);
	if (err == B_OK)
		return;

	BAlert* alert = new BAlert("media_server", "Launching media_addon_server "
		"failed.\n\nmedia_server will terminate", "OK");
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
	fprintf(stderr, "Launching media_addon_server (%s) failed: %s\n",
		B_MEDIA_ADDON_SERVER_SIGNATURE, strerror(err));
	exit(1);
}