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


C++ BDirectory::GetNextRef方法代码示例

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


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

示例1:

int32_t
PDirectoryGetEntries(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 *outArgs = static_cast<PArgs*>(out);
	outArgs->MakeEmpty();
	
	PArgs nameList;
	backend->Rewind();
	entry_ref ref;
	while (backend->GetNextRef(&ref) == B_OK)
	{
		if (ref.name)
			outArgs->AddString("name", ref.name);
	}
	
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:26,代码来源:PDirectory.cpp

示例2: directoriesDeleter

void
AddOnManager::RegisterAddOns()
{
	// Check if add-ons are already registered.
	if (!fReaderList.IsEmpty() || !fWriterList.IsEmpty()
		|| !fDecoderList.IsEmpty() || !fEncoderList.IsEmpty()) {
		return;
	}

	char** directories = NULL;
	size_t directoryCount = 0;

	if (find_paths_etc(get_architecture(), B_FIND_PATH_ADD_ONS_DIRECTORY,
			"media/plugins", B_FIND_PATH_EXISTING_ONLY, &directories,
			&directoryCount) != B_OK) {
		return;
	}

	MemoryDeleter directoriesDeleter(directories);

	BPath path;
	for (uint i = 0; i < directoryCount; i++) {
		BDirectory directory;
		if (directory.SetTo(directories[i]) == B_OK) {
			entry_ref ref;
			while(directory.GetNextRef(&ref) == B_OK)
				_RegisterAddOn(ref);
		}
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:30,代码来源:AddOnManager.cpp

示例3: KeymapListItem

void
KeymapWindow::_FillUserMaps()
{
	BListItem* item;
	while ((item = fUserListView->RemoveItem(static_cast<int32>(0))))
		delete item;

	entry_ref ref;
	_GetCurrentKeymap(ref);

	fUserListView->AddItem(new KeymapListItem(ref, TR("(Current)")));

	fCurrentMapName = _GetActiveKeymapName();

	BPath path;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
		return;

	path.Append("Keymap");

	BDirectory directory;
	if (directory.SetTo(path.Path()) == B_OK) {
		while (directory.GetNextRef(&ref) == B_OK) {
			fUserListView->AddItem(new KeymapListItem(ref));
		}
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:27,代码来源:KeymapWindow.cpp

示例4: sizeof

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) {
			entry_ref ref;
			while (directory.GetNextRef(&ref) == B_OK) {
				if (menu->FindItem(ref.name) != NULL)
					continue;

				BMessage* message = new BMessage(kChangeKeyboardLayout);
				message->AddRef("ref", &ref);

				menu->AddItem(new BMenuItem(ref.name, message));
			}
		}
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:32,代码来源:KeymapWindow.cpp

示例5: BMenu

/*!	Adds a menu populated with the keyboard layouts found in the passed
	in directory to the passed in menu. Each subdirectory in the passed
	in directory is added as a submenu recursively.
*/
void
KeymapWindow::_AddKeyboardLayoutMenu(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(B_TRANSLATE_NOCOLLECT(ref.name));

			_AddKeyboardLayoutMenu(submenu, subdirectory);
			menu->AddItem(submenu);
		} else {
			BMessage* message = new BMessage(kChangeKeyboardLayout);

			message->AddRef("ref", &ref);
			menu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(ref.name),
				message));
		}
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:29,代码来源:KeymapWindow.cpp

示例6: curImage

// Function taken from Haiku ShowImage,
// function originally written by Michael Pfeiffer
bool
SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind)
{
//	ASSERT(next || !rewind);
	BEntry curImage(in_current);
	entry_ref entry, *ref;
	BDirectory parent;
	BList entries;
	bool found = false;
	int32 cur;

	if (curImage.GetParent(&parent) != B_OK)
		return false;

	while (parent.GetNextRef(&entry) == B_OK) {
		if (entry != *in_current) {
			entries.AddItem(new entry_ref(entry));
		} else {
			// insert current ref, so we can find it easily after sorting
			entries.AddItem(in_current);
		}
	}

	entries.SortItems(CompareEntries);

	cur = entries.IndexOf(in_current);
//	ASSERT(cur >= 0);

	// remove it so FreeEntries() does not delete it
	entries.RemoveItem(in_current);

	if (next) {
		// find the next image in the list
		if (rewind) cur = 0; // start with first
		for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {
			if (IsImage(ref)) {
				found = true;
				*out_image = (const entry_ref)*ref;
				break;
			}
		}
	} else {
		// find the previous image in the list
		cur --;
		for (; cur >= 0; cur --) {
			ref = (entry_ref*)entries.ItemAt(cur);
			if (IsImage(ref)) {
				found = true;
				*out_image = (const entry_ref)*ref;
				break;
			}
		}
	}

	FreeEntries(&entries);
	return found;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:59,代码来源:SlideShowSaver.cpp

示例7: _

status_t
DecorInfoUtility::_ScanDecorators(BDirectory decoratorDirectory)
{
	BAutolock _(fLock);

	// First, run through our list and DecorInfos CheckForChanges()
	if (fHasScanned) {
		for (int i = fList.CountItems() - 1; i > 0; --i) {
			DecorInfo* decorInfo = fList.ItemAt(i);

			bool deleted = false;
			decorInfo->CheckForChanges(deleted);

			if (deleted) {
				fList.RemoveItem(decorInfo);
				delete decorInfo;
			}
		}
	}

	entry_ref ref;
	// Now, look at file system, skip the entries for which we already have
	// a DecorInfo in the list.
	while (decoratorDirectory.GetNextRef(&ref) == B_OK) {
		BPath path(&decoratorDirectory);
		status_t result = path.Append(ref.name);
		if (result != B_OK) {
			fprintf(stderr, "DecorInfoUtility::_ScanDecorators()\tFailed to"
				"append decorator file to path, skipping: %s.\n", strerror(result));
			continue;
		}
		if (_FindDecor(path.Path()) != NULL)
			continue;

		DecorInfo* decorInfo = new(std::nothrow) DecorInfo(ref);
		if (decorInfo == NULL || decorInfo->InitCheck() != B_OK) {
			fprintf(stderr, "DecorInfoUtility::_ScanDecorators()\tInitCheck() "
				"failure on decorator, skipping.\n");
			delete decorInfo;
			continue;
		}

		fList.AddItem(decorInfo);
	}

	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:47,代码来源:DecorInfo.cpp

示例8: KeymapListItem

void
VirtualKeyboardWindow::_LoadMaps()
{
	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) {
			fMapListView->AddItem(new KeymapListItem(ref));	
		}
	}
	fMapListView->SortItems(&compare_key_list_items);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:18,代码来源:VirtualKeyboardWindow.cpp

示例9: node

void
BootPromptWindow::_PopulateKeymaps()
{
	// Disable sending the selection message while we change the selection.
	fKeymapsListView->SetSelectionMessage(NULL);

	// Clean the list view first
	while (BListItem* item = fKeymapsListView->RemoveItem(
			fKeymapsListView->CountItems() - 1)) {
		delete item;
	}

	// Get the name of the current keymap, so we can mark the correct entry
	// in the list view.
	BString currentKeymapName;
	entry_ref ref;
	if (_GetCurrentKeymapRef(ref) == B_OK) {
		BNode node(&ref);
		node.ReadAttrString("keymap:name", &currentKeymapName);
	}

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

	// Populate the list
	BDirectory directory;
	if (directory.SetTo(path.Path()) == B_OK) {
		while (directory.GetNextRef(&ref) == B_OK) {
			fKeymapsListView->AddItem(new KeymapListItem(ref));
			if (currentKeymapName == ref.name)
				fKeymapsListView->Select(fKeymapsListView->CountItems() - 1);
		}
	}

	fKeymapsListView->ScrollToSelection();

	// Re-enable sending the selection message.
	fKeymapsListView->SetSelectionMessage(
		new BMessage(MSG_KEYMAP_SELECTED));
}
开发者ID:mmanley,项目名称:Antares,代码行数:44,代码来源:BootPromptWindow.cpp

示例10: node

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;
		BList itemsList;
		while (directory.GetNextRef(&ref) == B_OK) {
			BMessage* message = new BMessage(MSG_KEYMAP_SELECTED);
			message->AddRef("ref", &ref);
			BMenuItem* item = new BMenuItem(ref.name, message);
			itemsList.AddItem(item);
			if (currentName == ref.name)
				item->SetMarked(true);

			if (usInternational == ref.name)
				fDefaultKeymapItem = item;
		}
		itemsList.SortItems(compare_void_menu_items);
		fKeymapsMenuField->Menu()->AddList(&itemsList, 0);
	}
}
开发者ID:looncraz,项目名称:haiku,代码行数:43,代码来源:BootPromptWindow.cpp

示例11: themepath

status_t
ThemeManager::LoadThemes()
{
	FENTRY;
	int dirwhich;
	BPath path;
	BDirectory dir;
	entry_ref ref;
	status_t err;
	
	for (dirwhich = 0; dirwhich < 2; dirwhich++) {
		if (!dirwhich)	/* find system settings dir */
			err = find_directory(B_BEOS_ETC_DIRECTORY, &path);
		else			/* find user settings dir */
			err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
		if (err)	return err;
		
		err = dir.SetTo(path.Path());
		if (err)	return err;
		BEntry ent;
		if (dir.FindEntry(Z_THEMES_FOLDER_NAME, &ent) < B_OK) {
			dir.CreateDirectory(Z_THEMES_FOLDER_NAME, NULL);
		}
		
		path.Append(Z_THEMES_FOLDER_NAME);
		
		err = dir.SetTo(path.Path());
		if (err)	return err;
		
		err = dir.Rewind();
		if (err)	return err;
		
		while ((err = dir.GetNextRef(&ref)) == B_OK) {
			BPath themepath(&ref);
			BDirectory tdir(themepath.Path());
			err = tdir.InitCheck();
			if (err) /* not a dir */
				continue;
			err = LoadTheme(themepath.Path());
		}
	}
	return B_OK;
}
开发者ID:mmanley,项目名称:Antares,代码行数:43,代码来源:ThemeManager.cpp

示例12: open

PowerButtonMonitor::PowerButtonMonitor()
	:
	fFDs()
{
	BDirectory dir;
	if (dir.SetTo(kBasePath) != B_OK)
		return;

	entry_ref ref;
	while (dir.GetNextRef(&ref) == B_OK) {
		if (strncmp(ref.name, "power", 5) == 0) {
			BString path;
			path.SetToFormat("%s/%s", kBasePath, ref.name);
			int fd = open(path.String(), O_RDONLY);
			if (fd > 0)
				fFDs.insert(fd);
		}
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:19,代码来源:power_button_monitor.cpp

示例13: BMenu

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));
		}
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:22,代码来源:VirtualKeyboardWindow.cpp

示例14: filepath

void
ProjectWindow::AddFolder(entry_ref folderref)
{
	BDirectory dir;
	if (dir.SetTo(&folderref) != B_OK)
		return;
	
	if (strcmp(folderref.name,"CVS") == 0 ||
		strcmp(folderref.name,".svn") == 0 ||
		strcmp(folderref.name,".git") == 0 ||
		strcmp(folderref.name,".hg") == 0)
		return;
	
	dir.Rewind();
	
	entry_ref ref;
	while (dir.GetNextRef(&ref) == B_OK)
	{
		if (BEntry(&ref).IsDirectory())
			AddFolder(ref);
		else
		{
			// Here is where we actually add the file to the project. The name of the folder
			// containing the file will be the name of the file's group. If the group doesn't
			// exist, it will be created at the end of the list, but if it does, we will fake
			// a drop onto the group item to reuse the code path by finding the group and getting
			// its position in the list.
			
			DPath filepath(ref);
			if (filepath.GetExtension() && 
				!( strcmp(filepath.GetExtension(),"cpp") == 0 ||
				strcmp(filepath.GetExtension(),"c") == 0 ||
				strcmp(filepath.GetExtension(),"cc") == 0 ||
				strcmp(filepath.GetExtension(),"cxx") == 0 ||
				strcmp(filepath.GetExtension(),"rdef") == 0 ||
				strcmp(filepath.GetExtension(),"rsrc") == 0) )
				continue;
			
			// Don't bother adding build files from other systems
			if (strcmp(filepath.GetFileName(), "Jamfile") == 0 ||
				strcmp(filepath.GetFileName(), "Makefile") == 0)
				continue;
			
			DPath parent(filepath.GetFolder());
			SourceGroup *group = NULL;
			SourceGroupItem *groupItem = NULL;
			
			fProject->Lock();
			group = fProject->FindGroup(parent.GetFileName());
			
			Lock();
			if (group)
				groupItem = fProjectList->ItemForGroup(group);
			else
			{
				group = fProject->AddGroup(parent.GetFileName());
				groupItem = new SourceGroupItem(group);
				fProjectList->AddItem(groupItem);
				UpdateIfNeeded();
			}
			
			if (groupItem)
			{
				int32 index = fProjectList->IndexOf(groupItem);
				BPoint pt = fProjectList->ItemFrame(index).LeftTop();
				pt.x += 5;
				pt.y += 5;
				
				AddFile(ref,&pt);
			}
			
			Unlock();
				
			fProject->Unlock();
		}
	}
}
开发者ID:passick,项目名称:Paladin,代码行数:77,代码来源:ProjectWindow.cpp

示例15: imgpath

status_t
ThemeManager::LoadAddons()
{
	FENTRY;
	ThemesAddon *ta;
	BPath path;
	BDirectory dir;
	entry_ref ref;
#ifndef SINGLE_BINARY
	uint32 addonFlags;
	int dirwhich;
	int32 i;
	status_t err;
	image_id img;
	ThemesAddon *(*instantiate_func)();
#endif
	
#ifndef SINGLE_BINARY
	for (dirwhich = 0; dirwhich < 2; dirwhich++) {
		if (!dirwhich)	/* find system settings dir */
			err = find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
		else			/* find user settings dir */
			err = find_directory(B_USER_ADDONS_DIRECTORY, &path);
		if (err)	return err;
		
		path.Append(Z_THEMES_ADDON_FOLDER);
		
		err = dir.SetTo(path.Path());
		if (err)	continue;
		
		err = dir.Rewind();
		if (err)	continue;
		
		while ((err = dir.GetNextRef(&ref)) == B_OK) {
			bool screwed = false;
			BPath imgpath(&ref);
			BString p(Z_THEMES_ADDON_FOLDER);
			p << "/" << ref.name;
			PRINT(("ThemeManager: trying to load_add_on(%s)\n", p.String()));
			img = load_add_on(imgpath.Path());
			if (img < B_OK)
				fprintf(stderr, "ThemeManager: load_add_on 0x%08lx\n", img);
			if (img < B_OK)
				continue;
			err = get_image_symbol(img, "instantiate_themes_addon", 
							B_SYMBOL_TYPE_TEXT, (void **)&instantiate_func);
			if (err)
				fprintf(stderr, "ThemeManager: get_image_symbol 0x%08lx\n", err);
			if (err)	continue;
			ta = instantiate_func();
			if (!ta)
				fprintf(stderr, "ThemeManager: instantiate_themes_addon returned NULL\n");
			if (!ta)
				continue;
			ta->SetImageId(img);
			/* check for existing names */
			for (i = 0; i < fAddonList.CountItems(); i++) {
				ThemesAddon *a = AddonAt(i);
				if (!a)
					fprintf(stderr, "ThemeManager: screwed! [email protected]%ld null\n", i);
				if (a->MessageName() && ta->MessageName() && 
							!strcmp(a->MessageName(), ta->MessageName())) {
					fprintf(stderr, "ThemeManager: screwed! [email protected]%ld has same msgname\n", i);
					screwed = true;
					break;
				}
				if (a->Name() && ta->Name() && 
							!strcmp(a->Name(), ta->Name())) {
					fprintf(stderr, "ThemeManager: screwed! [email protected]%ld has same name\n", i);
					screwed = true;
					break;
				}
			}
			if (screwed)
				continue;
			/* add it to the list */
			fAddonList.AddItem((void *)ta);
			PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
		}
		//if (err)	return err;
	}
#else

#define ADDA(a) \
	if (ta) { \
		fAddonList.AddItem((void *)ta); \
		PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName())); \
	}


	ta = instantiate_themes_addon_backgrounds();
	ADDA(ta);
	ta = instantiate_themes_addon_beide();
	ADDA(ta);
	ta = instantiate_themes_addon_deskbar();
	ADDA(ta);
#ifndef ZETA_ADDONS
	ta = instantiate_themes_addon_eddie();
	ADDA(ta);
#endif
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:ThemeManager.cpp


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